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.


52
53
54
55
56
57
# File 'lib/dynamoid/validations.rb', line 52

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