Class: SchemaValidations::Validators::NotNilValidator

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

Overview

Validates that the field is not nil? (Unlike the standard PresenceValidator which uses #blank?)

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attr_name, value) ⇒ Object



6
7
8
# File 'lib/schema_validations/validators/not_nil_validator.rb', line 6

def validate_each(record, attr_name, value)
  record.errors.add(attr_name, :blank, options) if value.nil?
end