class Dynamoid::Validations::ClassMethods::PresenceValidator

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

Public Instance Methods

validate_each(record, attr_name, value) click to toggle source

Validate the record for the record and value.

# 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

Private Instance Methods

not_present?(value) click to toggle source

Check whether a value is not present.

# File lib/dynamoid/validations.rb, line 68
def not_present?(value)
  value.blank? && value != false
end