Class: Validation::Rule::Uuid
- Inherits:
-
Object
- Object
- Validation::Rule::Uuid
- Defined in:
- lib/validation/rule/uuid.rb
Defined Under Namespace
Classes: UnknownVersion
Instance Method Summary collapse
- #error_key ⇒ Object
-
#initialize(params) ⇒ Uuid
constructor
params can be any of the folowing:.
- #params ⇒ Object
- #valid_value?(value) ⇒ Boolean
Constructor Details
#initialize(params) ⇒ Uuid
params can be any of the folowing:
-
:version - v4
v5 uuid (Any valid uuid)
Example:
=> v4
15 16 17 |
# File 'lib/validation/rule/uuid.rb', line 15 def initialize(params) @params = params end |
Instance Method Details
#error_key ⇒ Object
29 30 31 |
# File 'lib/validation/rule/uuid.rb', line 29 def error_key :uuid end |
#params ⇒ Object
19 20 21 |
# File 'lib/validation/rule/uuid.rb', line 19 def params @params end |
#valid_value?(value) ⇒ Boolean
23 24 25 26 27 |
# File 'lib/validation/rule/uuid.rb', line 23 def valid_value?(value) value.nil? || !!uuid_regex.match(value.to_s) rescue UnknownVersion false end |