Class: ActiveModel::Validations::SshPublicKeyValidator

Inherits:
EachValidator
  • Object
show all
Defined in:
lib/validators/validates_ssh_public_key.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/validators/validates_ssh_public_key.rb', line 4

def validate_each(record, attribute, value)
  return if value.blank? && options[:allow_blank]
  return if value.nil? && options[:allow_nil]

  record.errors.add(attribute, :invalid_ssh_public_key,
    message: options[:message],
    value: value
  ) unless SSHKey.valid_ssh_public_key?(value)
end