Class: ActiveModel::Validations::LessValidator
- Inherits:
-
EachValidator
- Object
- EachValidator
- ActiveModel::Validations::LessValidator
- Defined in:
- lib/evelpidon_validators/less.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.less?(value, than) ⇒ Boolean
4 5 6 |
# File 'lib/evelpidon_validators/less.rb', line 4 def self.less?(value, than) value.present? and than.present? and value < than end |
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
8 9 10 11 12 |
# File 'lib/evelpidon_validators/less.rb', line 8 def validate_each(record, attribute, value) unless self.class.less? value, record.send([:than]) or ([:or_equal] && value.eql?(record.send([:than]))) record.errors.add(attribute, :less, ) end end |