Sha256: 09e248666c7dfa7acde04fe9f0fd798c7eb9ec34ef9d17e94e715b39c8165de4
Contents?: true
Size: 568 Bytes
Versions: 5
Compression:
Stored size: 568 Bytes
Contents
# Add an ActiveModel Validator # # Example: # class MyModel < ActiveRecord::Base # validates :encrypted_ssn, symmetric_encryption: true # end # # m = MyModel.new # m.valid? # # => false # m.encrypted_ssn = SymmetricEncryption.encrypt('123456789') # m.valid? # # => true class SymmetricEncryptionValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) return if value.blank? || SymmetricEncryption.encrypted?(value) record.errors.add(attribute, "must be a value encrypted using SymmetricEncryption.encrypt") end end
Version data entries
5 entries across 5 versions & 1 rubygems