StringFieldValidators extension

Validation and helper extensions for Field<String>.

All validator methods return this to allow method chaining on the field builder. The shared message and exposed parameters follow the same convention as Field.addValidator:

  • message — static error string shown when validation fails.
  • exposed — when true, the rule appears in Field.exposedRules.
on

Properties

text String

Available on Field<String>, provided by the StringFieldValidators extension

The current value as a non-nullable string, or an empty string when Field.value is null.
no setter

Methods

alphanumeric({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string contains only alphanumeric characters (a–z, A–Z, 0–9).
base64({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is a valid standard base64 encoded string.
base64url({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is a valid URL-safe base64 encoded string (uses - and _ instead of + and /).
cidrv4({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is an IPv4 CIDR notation address (e.g. 192.168.0.0/24).
cidrv6({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is an IPv6 CIDR notation address (e.g. 2001:db8::/32).
contains(String substring, {String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string contains substring.
cuid({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is a well-formed CUID identifier.
cuid2({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is a well-formed CUID2 identifier.
date({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is a date in YYYY-MM-DD format.
datetime({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is an ISO 8601 datetime (e.g. 2024-06-01T14:30:00Z).
email({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is a well-formed email address.
emoji({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string contains at least one emoji character.
endsWith(String suffix, {String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string ends with suffix.
equals(Field<String> getOtherField(ValueOf valueOf), {String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that this field's value equals the value of the field returned by getOtherField.
guid({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is a well-formed GUID (alias for uuidv4).
hash(String algorithm, {String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is a valid cryptographic hash for the given algorithm.
hasNoSequentialCharacters({int seqLength = 3, String message = ''}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string does not contain ascending or descending sequential character runs of length seqLength or more.
hasNoSequentialRepeatedCharacters({int maxRepeated = 3, String message = ''}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string does not contain a run of maxRepeated or more identical consecutive characters.
hex({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string contains only hexadecimal characters (0–9, a–f, A–F).
hostname({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is a well-formed hostname (e.g. example.com).
httpUrl({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is an absolute HTTP or HTTPS URL.
ipv4({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is a valid IPv4 address (e.g. 192.168.0.1).
ipv6({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is a valid IPv6 address.
isEmpty({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is empty (or null).
isoDate({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is an ISO date in YYYY-MM-DD format.
isoDatetime({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is an ISO 8601 datetime. Alias for datetime.
isoDuration({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is an ISO 8601 duration (e.g. P1Y2M3DT4H5M6S).
isoTime({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is an ISO time with optional timezone offset (e.g. 14:30:00Z or 14:30:00+03:00).
jwt({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is a well-formed JSON Web Token (header.payload.signature, each part base64url-encoded).
length(int exactLength, {String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string has exactly exactLength characters.
lowercase({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that all characters in the string are lowercase.
mac({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is a valid MAC address, with colons or hyphens (e.g. 00:1A:2B:3C:4D:5E or 00-1A-2B-3C-4D-5E).
maskCPFOrCNPJ({bool removeMaskOnJson = true}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Applies a dynamic CPF/CNPJ mask that switches format based on the number of digits typed.
matches(String otherFieldPath, {String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that this field's value equals the value of the field at otherFieldPath in the same form.
matchesPattern(RegExp regex, {String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string matches regex.
maxLength(int length, {String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string has at most length characters.
minLength(int length, {String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string has at least length characters.
mustHaveLowercase({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string contains at least one lowercase letter (a–z).
mustHaveNumber({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string contains at least one digit (0–9).
mustHaveNumbers({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string contains at least one digit (0–9).
mustHaveSpecialChar({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string contains at least one special character from the set !@#$%^&*(),.?":{}|<>.
mustHaveSpecialCharacter({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string contains at least one special character.
mustHaveUppercase({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string contains at least one uppercase letter (A–Z).
nanoid({int size = 21, String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is a well-formed Nano ID of the given size.
notEmpty({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is not empty (and not null).
numeric({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string contains only digit characters (0–9).
oneOf(List<String> allowedValues, {String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the value is one of allowedValues.
pattern(RegExp regex, {String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string matches the given regex.
required({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the value is not null and not blank (not empty after trim).
startsWith(String prefix, {String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string starts with prefix.
time({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is a time in HH:mm:ss format with optional milliseconds (e.g. 14:30:00 or 14:30:00.123).
ulid({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is a well-formed ULID (Universally Unique Lexicographically Sortable Identifier).
uppercase({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that all characters in the string are uppercase.
uuid({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is a well-formed UUID (any version).
uuidv4({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is a well-formed UUID v4.
uuidv6({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is a well-formed UUID v6.
uuidv7({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is a well-formed UUID v7.
validCEP({String message = ''}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is a valid Brazilian CEP (postal code).
validCNPJ({String message = ''}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is a valid Brazilian CNPJ number.
validCPF({String message = ''}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is a valid Brazilian CPF number.
validCPFOrCNPJ({String message = ''}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is a valid Brazilian CPF or CNPJ number.
validCreditCard({String message = ''}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is a valid credit card number using the Luhn algorithm.
validPhoneBR({String message = ''}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is a valid Brazilian mobile phone number in the format xx9xxxxxxxx (11 digits, DDD + 9 + 8 digits).
validPhoneWithCountryCodeBR({String message = ''}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is a valid Brazilian phone number including the country code 55 (format 55xx9xxxxxxxx, 13 digits).
validUrl({String message = '', bool exposed = false}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Validates that the string is a valid URL (with or without scheme).
when(bool condition(ValueOf valueOf), {String message = ''}) Field<String>

Available on Field<String>, provided by the StringFieldValidators extension

Makes required conditional on condition evaluating to true.