Class: CertificateValidator

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

Overview

UrlValidator

Custom validator for private keys.

class Project < ActiveRecord::Base
  validates :certificate_key, certificate: true
end

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object


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

def validate_each(record, attribute, value)
  unless valid_certificate_pem?(value)
    record.errors.add(attribute, "must be a valid PEM certificate")
  end
end