Class: Validators::AbsenceValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- Validators::AbsenceValidator
- Defined in:
- lib/validators/absence_validator.rb
Overview
Checks that an attribute is absent. The opposite of Rails’s PresenceValidator
Instance Method Summary collapse
-
#validate_each(record, attribute, value) ⇒ Object
This is a Rails method for custom Validators.
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
This is a Rails method for custom Validators. Please read the Rails docs for more info
7 8 9 |
# File 'lib/validators/absence_validator.rb', line 7 def validate_each(record, attribute, value) record.errors.add(attribute, :invalid, ) unless value.blank? end |