Class: FunWithJsonApi::Attributes::UuidV4Attribute
- Inherits:
-
FunWithJsonApi::Attribute
- Object
- FunWithJsonApi::Attribute
- FunWithJsonApi::Attributes::UuidV4Attribute
- Defined in:
- lib/fun_with_json_api/attributes/uuid_v4_attribute.rb
Overview
Attribute that only accepts a properly generated and formatted UUID version 4 as described in RFC 4122
Constant Summary collapse
- UUID_V4_REGEX =
/\A[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-[a-f0-9]{12}\z/
Instance Attribute Summary
Attributes inherited from FunWithJsonApi::Attribute
Instance Method Summary collapse
Methods inherited from FunWithJsonApi::Attribute
create, #initialize, #param_value, #sanitize_attribute_method
Constructor Details
This class inherits a constructor from FunWithJsonApi::Attribute
Instance Method Details
#decode(value) ⇒ Object
9 10 11 12 13 |
# File 'lib/fun_with_json_api/attributes/uuid_v4_attribute.rb', line 9 def decode(value) return value if value.nil? || value =~ UUID_V4_REGEX raise build_invalid_attribute_error(value) end |