class CrSerializer::Assertions::UuidAssertion(ActualValueType)
- CrSerializer::Assertions::UuidAssertion(ActualValueType)
- CrSerializer::Assertions::Assertion
- Reference
- Object
Overview
Validates a string is a properly formatted RFC4122 UUID; either in hyphenated, hexstring, or urn formats.
Usable on only String
properties
Optional annotation fields:
- versions :
Array(UUID::Version)
- Only allow specific UUID versions. Default[UUID::Version::V1, UUID::Version::V2, UUID::Version::V3, UUID::Version::V4, UUID::Version::V5]
. - variants :
Array(UUID::Variant)
- Only allow specific UUID variants. Default `[UUID::Variant::RFC4122]. - strict :
Bool
- Only allow the hyphenated UUID format. Defaultfalse
.
@[Assert::Uuid]
property data : String
NOTE Nil values are considered valid
Defined in:
CrSerializer/assertions/uuid.crConstructors
Instance Method Summary
-
#actual
The current value of the property
-
#error_message : String
The message that will be shown if the assertion is not valid
-
#valid? : Bool
Returns true if the provided property passes the assertion, otherwise false.
Instance methods inherited from class CrSerializer::Assertions::Assertion
error_message : String
error_message,
field : String
field,
valid? : Bool
valid?
Constructor methods inherited from class CrSerializer::Assertions::Assertion
new(field : String, message : String | Nil)
new
Constructor Detail
def self.new(field : String, message : String | Nil, actual : String | Nil, versions : Array(UUID::Version) = [UUID::Version::V1, UUID::Version::V2, UUID::Version::V3, UUID::Version::V4, UUID::Version::V5], variants : Array(UUID::Variant) = [UUID::Variant::RFC4122], strict : Bool = false)
#
Instance Method Detail
def valid? : Bool
#
Description copied from class CrSerializer::Assertions::Assertion
Returns true if the provided property passes the assertion, otherwise false.
TODO make this abstract once this issue is resolved.