Sha256: 9e6d87cb477845db7735cd688f404f073677c0ca86389c30e47e23aef1084d9b
Contents?: true
Size: 567 Bytes
Versions: 2
Compression:
Stored size: 567 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
2 entries across 2 versions & 1 rubygems