Class: RangeSentenceValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- RangeSentenceValidator
- Defined in:
- lib/range_sentence_validator.rb
Instance Method Summary collapse
-
#validate_each(record, attribute, value) ⇒ Object
Validates whether the value of the specified attribute is of the correct form for RangeSentenceParser.
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
Validates whether the value of the specified attribute is of the correct form for RangeSentenceParser.
Usage:
class AccountingReport
include ActiveModel::Validations
validates :year_sentence, :range_sentence => true
end
11 12 13 |
# File 'lib/range_sentence_validator.rb', line 11 def validate_each(record, attribute, value) record.errors.add(attribute) if RangeSentenceParser.invalid?(value) end |