Class: Validators::AbsenceValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/validators/absence_validator.rb

Overview

Checks that an attribute is absent. The opposite of Rails's PresenceValidator

Instance Method Summary (collapse)

Instance Method Details

- (Object) validate_each(record, attribute, value)

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, options) unless value.blank?
end