Class: Validation::Rule::Guid
- Inherits:
-
Object
- Object
- Validation::Rule::Guid
- Defined in:
- lib/diaspora_federation/validators/rules/guid.rb
Overview
GUID validation rule
Valid is a String
that is at least 16 and at most 255 chars long. It contains only:
-
Letters: a-z
-
Numbers: 0-9
-
Special chars: ‘-’, ‘_’, ‘@’, ‘.’ and ‘:’
Special chars aren’t allowed at the end.
Constant Summary collapse
- VALID_CHARS =
Allowed chars to validate a GUID with a regex
"[0-9A-Za-z\\-_@.:]{15,254}[0-9A-Za-z]"
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
GUID
.
Instance Method Details
#error_key ⇒ Symbol
The error key for this rule
18 19 20 |
# File 'lib/diaspora_federation/validators/rules/guid.rb', line 18 def error_key :guid end |
#params ⇒ Hash
This rule has no params.
29 30 31 |
# File 'lib/diaspora_federation/validators/rules/guid.rb', line 29 def params {} end |
#valid_value?(value) ⇒ Boolean
Determines if value is a valid GUID
23 24 25 |
# File 'lib/diaspora_federation/validators/rules/guid.rb', line 23 def valid_value?(value) value.is_a?(String) && value =~ /\A#{VALID_CHARS}\z/ end |