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— whentrue, the rule appears in Field.exposedRules.
Properties
- text → String
-
Available on Field<
The current value as a non-nullable string, or an empty string when Field.value isString> , provided by the StringFieldValidators extensionnull.no setter
Methods
-
alphanumeric(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string contains only alphanumeric characters (a–z, A–Z, 0–9).String> , provided by the StringFieldValidators extension -
base64(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string is a valid standard base64 encoded string.String> , provided by the StringFieldValidators extension -
base64url(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string is a valid URL-safe base64 encoded string (usesString> , provided by the StringFieldValidators extension-and_instead of+and/). -
cidrv4(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string is an IPv4 CIDR notation address (e.g.String> , provided by the StringFieldValidators extension192.168.0.0/24). -
cidrv6(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string is an IPv6 CIDR notation address (e.g.String> , provided by the StringFieldValidators extension2001:db8::/32). -
contains(
String substring, {String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string containsString> , provided by the StringFieldValidators extensionsubstring. -
cuid(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string is a well-formed CUID identifier.String> , provided by the StringFieldValidators extension -
cuid2(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string is a well-formed CUID2 identifier.String> , provided by the StringFieldValidators extension -
date(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string is a date inString> , provided by the StringFieldValidators extensionYYYY-MM-DDformat. -
datetime(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string is an ISO 8601 datetime (e.g.String> , provided by the StringFieldValidators extension2024-06-01T14:30:00Z). -
email(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string is a well-formed email address.String> , provided by the StringFieldValidators extension -
emoji(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string contains at least one emoji character.String> , provided by the StringFieldValidators extension -
endsWith(
String suffix, {String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string ends withString> , provided by the StringFieldValidators extensionsuffix. -
equals(
Field< String> getOtherField(ValueOf valueOf), {String message = '', bool exposed = false}) → Field<String> -
Available on Field<
Validates that this field's value equals the value of the field returned byString> , provided by the StringFieldValidators extensiongetOtherField. -
guid(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string is a well-formed GUID (alias for uuidv4).String> , provided by the StringFieldValidators extension -
hash(
String algorithm, {String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string is a valid cryptographic hash for the givenString> , provided by the StringFieldValidators extensionalgorithm. -
hasNoSequentialCharacters(
{int seqLength = 3, String message = ''}) → Field< String> -
Available on Field<
Validates that the string does not contain ascending or descending sequential character runs of lengthString> , provided by the StringFieldValidators extensionseqLengthor more. -
hasNoSequentialRepeatedCharacters(
{int maxRepeated = 3, String message = ''}) → Field< String> -
Available on Field<
Validates that the string does not contain a run ofString> , provided by the StringFieldValidators extensionmaxRepeatedor more identical consecutive characters. -
hex(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string contains only hexadecimal characters (0–9, a–f, A–F).String> , provided by the StringFieldValidators extension -
hostname(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string is a well-formed hostname (e.g.String> , provided by the StringFieldValidators extensionexample.com). -
httpUrl(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string is an absolute HTTP or HTTPS URL.String> , provided by the StringFieldValidators extension -
ipv4(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string is a valid IPv4 address (e.g.String> , provided by the StringFieldValidators extension192.168.0.1). -
ipv6(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string is a valid IPv6 address.String> , provided by the StringFieldValidators extension -
isEmpty(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string is empty (orString> , provided by the StringFieldValidators extensionnull). -
isoDate(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string is an ISO date inString> , provided by the StringFieldValidators extensionYYYY-MM-DDformat. -
isoDatetime(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string is an ISO 8601 datetime. Alias for datetime.String> , provided by the StringFieldValidators extension -
isoDuration(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string is an ISO 8601 duration (e.g.String> , provided by the StringFieldValidators extensionP1Y2M3DT4H5M6S). -
isoTime(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string is an ISO time with optional timezone offset (e.g.String> , provided by the StringFieldValidators extension14:30:00Zor14:30:00+03:00). -
jwt(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string is a well-formed JSON Web Token (String> , provided by the StringFieldValidators extensionheader.payload.signature, each part base64url-encoded). -
length(
int exactLength, {String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string has exactlyString> , provided by the StringFieldValidators extensionexactLengthcharacters. -
lowercase(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that all characters in the string are lowercase.String> , provided by the StringFieldValidators extension -
mac(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string is a valid MAC address, with colons or hyphens (e.g.String> , provided by the StringFieldValidators extension00:1A:2B:3C:4D:5Eor00-1A-2B-3C-4D-5E). -
maskCPFOrCNPJ(
{bool removeMaskOnJson = true}) → Field< String> -
Available on Field<
Applies a dynamic CPF/CNPJ mask that switches format based on the number of digits typed.String> , provided by the StringFieldValidators extension -
matches(
String otherFieldPath, {String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that this field's value equals the value of the field atString> , provided by the StringFieldValidators extensionotherFieldPathin the same form. -
matchesPattern(
RegExp regex, {String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string matchesString> , provided by the StringFieldValidators extensionregex. -
maxLength(
int length, {String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string has at mostString> , provided by the StringFieldValidators extensionlengthcharacters. -
minLength(
int length, {String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string has at leastString> , provided by the StringFieldValidators extensionlengthcharacters. -
mustHaveLowercase(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string contains at least one lowercase letter (a–z).String> , provided by the StringFieldValidators extension -
mustHaveNumber(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string contains at least one digit (0–9).String> , provided by the StringFieldValidators extension -
mustHaveNumbers(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string contains at least one digit (0–9).String> , provided by the StringFieldValidators extension -
mustHaveSpecialChar(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string contains at least one special character from the setString> , provided by the StringFieldValidators extension!@#$%^&*(),.?":{}|<>. -
mustHaveSpecialCharacter(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string contains at least one special character.String> , provided by the StringFieldValidators extension -
mustHaveUppercase(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string contains at least one uppercase letter (A–Z).String> , provided by the StringFieldValidators extension -
nanoid(
{int size = 21, String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string is a well-formed Nano ID of the givenString> , provided by the StringFieldValidators extensionsize. -
notEmpty(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string is not empty (and notString> , provided by the StringFieldValidators extensionnull). -
numeric(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string contains only digit characters (0–9).String> , provided by the StringFieldValidators extension -
oneOf(
List< String> allowedValues, {String message = '', bool exposed = false}) → Field<String> -
Available on Field<
Validates that the value is one ofString> , provided by the StringFieldValidators extensionallowedValues. -
pattern(
RegExp regex, {String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string matches the givenString> , provided by the StringFieldValidators extensionregex. -
required(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the value is notString> , provided by the StringFieldValidators extensionnulland not blank (not empty after trim). -
startsWith(
String prefix, {String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string starts withString> , provided by the StringFieldValidators extensionprefix. -
time(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string is a time inString> , provided by the StringFieldValidators extensionHH:mm:ssformat with optional milliseconds (e.g.14:30:00or14:30:00.123). -
ulid(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string is a well-formed ULID (Universally Unique Lexicographically Sortable Identifier).String> , provided by the StringFieldValidators extension -
uppercase(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that all characters in the string are uppercase.String> , provided by the StringFieldValidators extension -
uuid(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string is a well-formed UUID (any version).String> , provided by the StringFieldValidators extension -
uuidv4(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string is a well-formed UUID v4.String> , provided by the StringFieldValidators extension -
uuidv6(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string is a well-formed UUID v6.String> , provided by the StringFieldValidators extension -
uuidv7(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string is a well-formed UUID v7.String> , provided by the StringFieldValidators extension -
validCEP(
{String message = ''}) → Field< String> -
Available on Field<
Validates that the string is a valid Brazilian CEP (postal code).String> , provided by the StringFieldValidators extension -
validCNPJ(
{String message = ''}) → Field< String> -
Available on Field<
Validates that the string is a valid Brazilian CNPJ number.String> , provided by the StringFieldValidators extension -
validCPF(
{String message = ''}) → Field< String> -
Available on Field<
Validates that the string is a valid Brazilian CPF number.String> , provided by the StringFieldValidators extension -
validCPFOrCNPJ(
{String message = ''}) → Field< String> -
Available on Field<
Validates that the string is a valid Brazilian CPF or CNPJ number.String> , provided by the StringFieldValidators extension -
validCreditCard(
{String message = ''}) → Field< String> -
Available on Field<
Validates that the string is a valid credit card number using the Luhn algorithm.String> , provided by the StringFieldValidators extension -
validPhoneBR(
{String message = ''}) → Field< String> -
Available on Field<
Validates that the string is a valid Brazilian mobile phone number in the formatString> , provided by the StringFieldValidators extensionxx9xxxxxxxx(11 digits, DDD + 9 + 8 digits). -
validPhoneWithCountryCodeBR(
{String message = ''}) → Field< String> -
Available on Field<
Validates that the string is a valid Brazilian phone number including the country codeString> , provided by the StringFieldValidators extension55(format55xx9xxxxxxxx, 13 digits). -
validUrl(
{String message = '', bool exposed = false}) → Field< String> -
Available on Field<
Validates that the string is a valid URL (with or without scheme).String> , provided by the StringFieldValidators extension -
when(
bool condition(ValueOf valueOf), {String message = ''}) → Field< String> -
Available on Field<
Makes required conditional onString> , provided by the StringFieldValidators extensionconditionevaluating totrue.