Class: TimespanValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- TimespanValidator
- Defined in:
- lib/timespan_validator.rb
Instance Attribute Summary collapse
-
#attrib ⇒ Object
readonly
Returns the value of attribute attrib.
Instance Method Summary collapse
Instance Attribute Details
#attrib ⇒ Object (readonly)
Returns the value of attribute attrib.
2 3 4 |
# File 'lib/timespan_validator.rb', line 2 def attrib @attrib end |
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
4 5 6 7 |
# File 'lib/timespan_validator.rb', line 4 def validate_each(record, attribute, value) @attrib = attribute record.errors[attribute] << "must be within: #{show_range}" unless within? value end |