class Apes::Validators::UuidValidator
Validates UUIDs (version 4).
Constants
- VALID_REGEX
The pattern to recognized a valid UUID version 4.
Public Class Methods
new(options)
click to toggle source
Creates a new validator.
@param options [Hash] The options for the validations. @return [Apes::Validators::UuidValidator] A new validator.
Calls superclass method
# File lib/apes/validators.rb, line 72 def initialize(options) super(options.reverse_merge(default_message: "must be a valid UUID")) end
Public Instance Methods
check_valid?(value)
click to toggle source
Checks if the value is valid for this validator.
@param value [Object] The value to validate. @return [Boolean] `true` if the value is valid, false otherwise.
# File lib/apes/validators.rb, line 80 def check_valid?(value) value.blank? || value =~ VALID_REGEX end