Class: RsaKeyValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
app/validators/rsa_key_validator.rb

Overview

RsaKeyValidator

Custom validator for RSA private keys.

class Project < ActiveRecord::Base
  validates :signing_key, rsa_key: true
end

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



12
13
14
15
16
# File 'app/validators/rsa_key_validator.rb', line 12

def validate_each(record, attribute, value)
  unless valid_rsa_key?(value)
    record.errors.add(attribute, "is not a valid RSA key")
  end
end