Class: SequentialValidator
- Inherits:
-
ActiveModel::Validator
- Object
- ActiveModel::Validator
- SequentialValidator
- Defined in:
- lib/active_model/sequential_validator.rb
Instance Method Summary collapse
Instance Method Details
#validate(record) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/active_model/sequential_validator.rb', line 4 def validate(record) values = [:attributes].map do |attribute| record.send(attribute) end.compact if values.sort != values record.errors.add [:attributes].last, "cannot be before #{[:attributes].first}" end end |