Sha256: bc8a1f5a1e20104cb2dc9f3a6ff3fb2759cc5d97b13781431f292f048df9fbd9
Contents?: true
Size: 487 Bytes
Versions: 2
Compression:
Stored size: 487 Bytes
Contents
class CurrencyValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) unless valid?(value, options) record.errors[attribute] << (options[:message] || I18n.t('yukonisuru.errors.messages.currency')) end end private def valid_format?(value, options) if options[:strict] value =~ /^\d+(\.\d{2})$/ else value =~ /^\d*+(\.\d{1,2})$/ end end def valid?(value, options) valid_format?(value, options) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
yukonisuru-1.0.0 | lib/yukonisuru/validators/currency_validator.rb |
yukonisuru-0.0.1 | lib/yukonisuru/validators/currency_validator.rb |