Class: Dynamoid::Validations::ClassMethods::PresenceValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/dynamoid/validations.rb

Overview

Validates that the specified attributes are present (false or not blank).

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attr_name, value) ⇒ Object

Validate the record for the record and value.



58
59
60
61
62
63
# File 'lib/dynamoid/validations.rb', line 58

def validate_each(record, attr_name, value)
  # Use keyword argument `options` because it was a Hash in Rails < 6.1
  # and became a keyword argument in 6.1.  This way it works in both
  # cases.
  record.errors.add(attr_name, :blank, **options) if not_present?(value)
end