Sha256: 5539b948c659a05a0421ce3dae6828dc555474fa4a8b3752ab53e518da42e062
Contents?: true
Size: 493 Bytes
Versions: 11
Compression:
Stored size: 493 Bytes
Contents
class CurrencyValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) unless valid?(value, options) record.errors[attribute] << (options[:message] || I18n.t('flash_validators.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
11 entries across 11 versions & 1 rubygems