Class: Validation::Rule::Uuid

Inherits:
Object
  • Object
show all
Defined in:
lib/validation/rule/uuid.rb

Defined Under Namespace

Classes: UnknownVersion

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Uuid

params can be any of the folowing:

  • :version - v4 (only supports v4 at this time)

Example:

=> v4



13
14
15
# File 'lib/validation/rule/uuid.rb', line 13

def initialize(params)
  @params = params
end

Instance Method Details

#error_keyObject



27
28
29
# File 'lib/validation/rule/uuid.rb', line 27

def error_key
  :uuid
end

#paramsObject



17
18
19
# File 'lib/validation/rule/uuid.rb', line 17

def params
  @params
end

#valid_value?(value) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
25
# File 'lib/validation/rule/uuid.rb', line 21

def valid_value?(value)
  value.nil? || !!uuid_regex.match(value.to_s)
rescue UnknownVersion
  false
end