.uuid()
Passes when the string has the 8-4-4-4-12 hexadecimal shape of a UUID. Any version and variant digit is accepted.
Signature
Section titled “Signature”StringValidator<O> uuid({String? message, MessageBuilder? messageBuilder})Parameters
Section titled “Parameters”| Parameter | Type | Meaning |
|---|---|---|
message |
String? |
Replaces the default error message. |
messageBuilder |
MessageBuilder? |
Builds the message from the issue. message wins when both are given. See Message builders. |
Code invalidUuid. Default message: value must be a valid uuid. value is replaced by the field name when there is one.
Code generation
Section titled “Code generation”@IsUuid(), or the constant @isUuid. Put the annotation on the constructor parameter or the field.
Example
Section titled “Example”final id = l.string().uuid();@IsUuid() required String id, // l.string().uuid().required()id.validate(input)+1-1- valid:
'123e4567-e89b-12d3-a456-426614174000' - invalid:
'123'