Merge pull request #43021 from basecamp/encryption-lenght-validation
Minor improvements to Encryptable records
This commit is contained in:
commit
a2a399c6ae
@ -46,10 +46,10 @@ module EncryptableRecord
|
||||
# encryption is used, they will be used to generate additional ciphertexts to check in the queries.
|
||||
def encrypts(*names, key_provider: nil, key: nil, deterministic: false, downcase: false, ignore_case: false, previous: [], **context_properties)
|
||||
self.encrypted_attributes ||= Set.new # not using :default because the instance would be shared across classes
|
||||
scheme = scheme_for key_provider: key_provider, key: key, deterministic: deterministic, downcase: downcase, \
|
||||
ignore_case: ignore_case, previous: previous, **context_properties
|
||||
|
||||
names.each do |name|
|
||||
scheme = scheme_for key_provider: key_provider, key: key, deterministic: deterministic, downcase: downcase, \
|
||||
ignore_case: ignore_case, previous: previous, **context_properties
|
||||
encrypt_attribute name, scheme
|
||||
end
|
||||
end
|
||||
@ -133,7 +133,7 @@ def add_length_validation_for_encrypted_columns
|
||||
end
|
||||
|
||||
def validate_column_size(attribute_name)
|
||||
if table_exists? && limit = columns_hash[attribute_name.to_s]&.limit
|
||||
if limit = columns_hash[attribute_name.to_s]&.limit
|
||||
validates_length_of attribute_name, maximum: limit
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user