Class: FrakzioValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- FrakzioValidator
- Defined in:
- lib/frakzio_validator.rb
Instance Method Summary collapse
-
#validate_each(record, attribute, value) ⇒ Object
implement the method called during validation.
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
implement the method called during validation
3 4 5 6 7 8 |
# File 'lib/frakzio_validator.rb', line 3 def validate_each(record, attribute, value) if value value = value.to_s record.errors[attribute] << 'invalid format' unless value.match(/\A\d* *\d*\/?\d*\z/).to_s == value || value.match(/\A\d*\.?\d*\z/).to_s == value end end |