123456789_123456789_123456789_123456789_123456789_

Module: ActiveRecord::Encryption::ExtendedDeterministicUniquenessValidator::EncryptedUniquenessValidator

Instance Method Summary

Instance Method Details

#validate_each(record, attribute, value)

[ GitHub ]

  
# File 'activerecord/lib/active_record/encryption/extended_deterministic_uniqueness_validator.rb', line 11

def validate_each(record, attribute, value)
  super(record, attribute, value)

  klass = record.class
  if klass.deterministic_encrypted_attributes&.include?(attribute)
    encrypted_type = klass.type_for_attribute(attribute)
    encrypted_type.previous_types.each do |type|
      encrypted_value = type.serialize(value)
      ActiveRecord::Encryption.without_encryption do
        super(record, attribute, encrypted_value)
      end
    end
  end
end