6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/validators/validates_ssh_private_key.rb', line 6
def validate_each(record, attribute, value)
return if value.blank? && options[:allow_blank]
return if value.nil? && options[:allow_nil]
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: options[:message],
value: value
)
end
|