Class: ActiveModel::Validations::SshPrivateKeyValidator
- Inherits:
-
EachValidator
- Object
- EachValidator
- ActiveModel::Validations::SshPrivateKeyValidator
- Defined in:
- lib/validators/validates_ssh_private_key.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/validators/validates_ssh_private_key.rb', line 4 def validate_each(record, attribute, value) sshkey = SSHKey.new(value.to_s) validate_type(record, attribute, sshkey) validate_bits(record, attribute, sshkey) rescue OpenSSL::PKey::DSAError, OpenSSL::PKey::RSAError record.errors.add(attribute, :invalid_ssh_private_key, message: [:message], value: value ) end |