Class: Apes::Validators::UuidValidator
- Inherits:
-
BaseValidator
- Object
- ActiveModel::EachValidator
- BaseValidator
- Apes::Validators::UuidValidator
- Defined in:
- lib/apes/validators.rb
Overview
Validates UUIDs (version 4).
Constant Summary
- VALID_REGEX =
The pattern to recognized a valid UUID version 4.
/\A[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\z/i
Instance Method Summary (collapse)
-
- (Boolean) check_valid?(value)
Checks if the value is valid for this validator.
-
- (Apes::Validators::UuidValidator) initialize(options)
constructor
Creates a new validator.
Methods inherited from BaseValidator
Constructor Details
- (Apes::Validators::UuidValidator) initialize(options)
Creates a new validator.
72 73 74 |
# File 'lib/apes/validators.rb', line 72 def initialize() super(.reverse_merge(default_message: "must be a valid UUID")) end |
Instance Method Details
- (Boolean) check_valid?(value)
Checks if the value is valid for this validator.
80 81 82 |
# File 'lib/apes/validators.rb', line 80 def check_valid?(value) value.blank? || value =~ VALID_REGEX end |