Sha256: 63c01b2fe5fa02b37d611b269896a5691fafc9e43dd266118ddcdd61f456e66b
Contents?: true
Size: 905 Bytes
Versions: 2
Compression:
Stored size: 905 Bytes
Contents
# frozen_string_literal: true module ActiveModel module Validations class SshPublicKeyValidator < EachValidator def validate_each(record, attribute, value) return if value.blank? && options[:allow_blank] return if value.nil? && options[:allow_nil] return if SSHKey.valid_ssh_public_key?(value) record.errors.add( attribute, :invalid_ssh_public_key, message: options[:message], value: value ) end end module ClassMethods # Validates whether or not the specified CNPJ is valid. # # class User < ActiveRecord::Base # validates_ssh_public_key :key # end # def validates_ssh_public_key(*attr_names) Validators.require_dependency! "sshkey" validates_with SshPublicKeyValidator, _merge_attributes(attr_names) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
validators-3.4.2 | lib/validators/validates_ssh_public_key.rb |
validators-3.4.1 | lib/validators/validates_ssh_public_key.rb |