Class: CertificateFingerprintValidator

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

Constant Summary collapse

FINGERPRINT_PATTERN =
/\A([a-zA-Z0-9]{2}[\s\-:]?){16,}\z/

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



6
7
8
9
10
# File 'app/validators/certificate_fingerprint_validator.rb', line 6

def validate_each(record, attribute, value)
  unless value.try(:match, FINGERPRINT_PATTERN)
    record.errors.add(attribute, "must be a hash containing only letters, numbers, spaces, : and -")
  end
end