Class: ActiveModel::Validations::GreaterValidator
- Inherits:
-
EachValidator
- Object
- EachValidator
- ActiveModel::Validations::GreaterValidator
- Defined in:
- lib/evelpidon_validators/greater.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.greater?(value, than) ⇒ Boolean
4 5 6 |
# File 'lib/evelpidon_validators/greater.rb', line 4 def self.greater?(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/greater.rb', line 8 def validate_each(record, attribute, value) unless self.class.greater? value, record.send([:than]) or ([:or_equal] && value.eql?(record.send([:than]))) record.errors.add(attribute, :greater, ) end end |