Class: RangeSentenceValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/range_sentence_validator.rb

Instance Method Summary collapse

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