Class: ActiveInteraction::Extras::Filters::UUIDFilter

Inherits:
StringFilter
  • Object
show all
Defined in:
lib/active_interaction/extras/filters/uuid_filter.rb

Constant Summary collapse

REGEX =
/^[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i.freeze

Instance Method Summary collapse

Instance Method Details

#convert(value) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/active_interaction/extras/filters/uuid_filter.rb', line 12

def convert(value)
  value, error = super
  if error
    [value, error]
  else
    [value&.presence, nil]
  end
end

#matches?(value) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/active_interaction/extras/filters/uuid_filter.rb', line 8

def matches?(value)
  super && REGEX.match?(value)
end