Class: RangeValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- RangeValidator
- Defined in:
- lib/simple_range_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.
5 6 7 |
# File 'lib/simple_range_validator.rb', line 5 def attrib @attrib end |
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
7 8 9 10 |
# File 'lib/simple_range_validator.rb', line 7 def validate_each(record, attribute, value) @attrib = attribute record.errors[attribute] << "must be within: #{show_range}" unless within? value end |