Class: Validation::Rule::PublicKey
- Inherits:
-
Object
- Object
- Validation::Rule::PublicKey
- Defined in:
- lib/diaspora_federation/validators/rules/public_key.rb
Overview
Public key validation rule
A valid key must:
-
start with “—–BEGIN PUBLIC KEY—–” and end with “—–END PUBLIC KEY—–”
or
-
start with “—–BEGIN RSA PUBLIC KEY—–” and end with “—–END RSA PUBLIC KEY—–”
Instance Method Summary collapse
-
#error_key ⇒ Symbol
The error key for this rule.
-
#params ⇒ Hash
This rule has no params.
-
#valid_value?(value) ⇒ Boolean
Determines if value is a valid public key.
Instance Method Details
#error_key ⇒ Symbol
The error key for this rule
14 15 16 |
# File 'lib/diaspora_federation/validators/rules/public_key.rb', line 14 def error_key :public_key end |
#params ⇒ Hash
This rule has no params.
30 31 32 |
# File 'lib/diaspora_federation/validators/rules/public_key.rb', line 30 def params {} end |
#valid_value?(value) ⇒ Boolean
Determines if value is a valid public key
19 20 21 22 23 24 25 26 |
# 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 |