Skip to content

.cuid()

Passes when the whole string is a c followed by at least eight characters that are not whitespace or -, case-insensitively. This is a format check only.

StringValidator<O> cuid({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 invalidCuid. Default message: value must be a valid cuid. value is replaced by the field name when there is one.

@IsCuid(), or the constant @isCuid. Put the annotation on the constructor parameter or the field.

final id = l.string().cuid();
id.validate(input)+1-2
  1. valid: 'cjld2cjxh0000qzrmn831i7rn'
  2. invalid: 'xcjld2cjxh0000qzrmn831i7rn'value must be a valid cuid
  3. invalid: '123'value must be a valid cuid