Class: Dynamoid::Validations::UniquenessValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- Dynamoid::Validations::UniquenessValidator
- Defined in:
- lib/activity_notification/orm/dynamoid/extension.rb
Overview
Validates whether or not a field is unique against the records in the database.
Instance Method Summary collapse
-
#validate_each(document, attribute, value) ⇒ Object
Validate the document for uniqueness violations.
Instance Method Details
#validate_each(document, attribute, value) ⇒ Object
Validate the document for uniqueness violations.
98 99 100 101 102 103 104 |
# File 'lib/activity_notification/orm/dynamoid/extension.rb', line 98 def validate_each(document, attribute, value) return unless validation_required?(document, attribute) if not_unique?(document, attribute, value) = .except(:scope).merge(value: value) document.errors.add(attribute, :taken, **) end end |