class Validation::Rule::PublicKey

Public key validation rule

A valid key must:

or

Public Instance Methods

error_key() click to toggle source

The error key for this rule @return [Symbol] error key

# File lib/diaspora_federation/validators/rules/public_key.rb, line 14
def error_key
  :public_key
end
params() click to toggle source

This rule has no params. @return [Hash] params

# File lib/diaspora_federation/validators/rules/public_key.rb, line 30
def params
  {}
end
valid_value?(value) click to toggle source

Determines if value is a valid public key

# File lib/diaspora_federation/validators/rules/public_key.rb, line 19
def valid_value?(value)
  !value.nil? && (
    (value.strip.start_with?("-----BEGIN PUBLIC KEY-----") &&
     value.strip.end_with?("-----END PUBLIC KEY-----")) ||
    (value.strip.start_with?("-----BEGIN RSA PUBLIC KEY-----") &&
      value.strip.end_with?("-----END RSA PUBLIC KEY-----"))
  )
end