Skip to content

.uuid()

Passes when the string has the 8-4-4-4-12 hexadecimal shape of a UUID. Any version and variant digit is accepted.

StringValidator<O> uuid({String? message, MessageBuilder? messageBuilder})
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.

@IsUuid(), or the constant @isUuid. Put the annotation on the constructor parameter or the field.

final id = l.string().uuid();
id.validate(input)+1-1
  1. valid: '123e4567-e89b-12d3-a456-426614174000'
  2. invalid: '123'value must be a valid uuid