validation library

Classes

EmailBlockedDomainIssue
Email uses a blocked domain.
EmailDisposableDomainIssue
Email uses a disposable domain.
EmailDomainTooLongIssue
Email domain exceeds the configured maximum length.
EmailEmptyIssue
Email input is empty.
EmailInvalidFormatIssue
Email does not match the expected format.
EmailLocalPartTooLongIssue
Email local part exceeds the configured maximum length.
EmailTooLongIssue
Email exceeds the configured maximum length.
EmailValidationConfig
Configuration for email validation.
EmailValidationIssue
Base type for email validation failures.
EmailValidator
Canonical validator for email inputs.
NumberDecimalPlacesExceededIssue
Number has too many decimal places.
NumberEmptyIssue
Number input is empty.
NumberInvalidFormatIssue
Number input is malformed.
NumberNegativeNotAllowedIssue
Negative values are not allowed.
NumberNotIntegerIssue
A whole number is required.
NumberTooLargeIssue
Number is larger than the allowed maximum.
NumberTooSmallIssue
Number is smaller than the allowed minimum.
NumberValidationConfig
Configuration for number validation.
NumberValidationIssue
Base type for number validation failures.
NumberValidator
Canonical validator for number inputs.
PasswordEmptyIssue
Password input is empty.
PasswordMissingDigitIssue
Password is missing a digit.
PasswordMissingLowercaseIssue
Password is missing a lowercase letter.
PasswordMissingSpecialCharacterIssue
Password is missing a special character.
PasswordMissingUppercaseIssue
Password is missing an uppercase letter.
PasswordRepeatedCharacterIssue
Password uses a repeated-character pattern.
PasswordSequentialPatternIssue
Password uses a sequential pattern.
PasswordStrength
Represents the strength grading of a given password.
PasswordTooCommonIssue
Password is too common.
PasswordTooLongIssue
Password is longer than allowed.
PasswordTooShortIssue
Password is shorter than allowed.
PasswordValidationConfig
Configuration for password validation.
PasswordValidationIssue
Base type for password validation failures.
PasswordValidator
Canonical validator for password inputs.
TextContainsBlacklistedIssue
Text contains blacklisted words.
TextEmptyIssue
Text input is empty.
TextInvalidCharactersIssue
Text includes disallowed characters.
TextInvalidPatternIssue
Text does not match the required pattern.
TextOnlyWhitespaceIssue
Text contains only whitespace.
TextTooLongIssue
Text is longer than allowed.
TextTooShortIssue
Text is shorter than allowed.
TextValidationConfig
Configuration for generic text validation.
TextValidationIssue
Base type for text validation failures.
TextValidator
Canonical validator for generic text inputs.
ValidationIssue
Base contract for typed validation failures.

Extensions

StringValidation on String
A vast collection of validation utilities mapped as getters on String.

Constants

emailRegStr → const String
RFC 5321/5322 local-part characters before @. Domain requires at least one . with a 2+ char TLD.

Properties

alphaNumericReg RegExp
A regular expression that matches any string containing only letters and numbers.
getter/setter pair
alphaNumericRegStr String
The pattern used by the alphaNumericReg regular expression.
getter/setter pair
alphaReg RegExp
A regular expression that matches any string containing only letters (a-zA-Z).
getter/setter pair
alphaRegStr String
The pattern used by the alphaReg regular expression.
getter/setter pair
asciiReg RegExp
This file contains a regular expression to match ASCII characters. A regular expression that matches any string containing only ASCII characters. The pattern used by the asciiReg regular expression.
getter/setter pair
asciiRegStr String
The pattern used by the asciiReg regular expression. The pattern matches any string that contains only ASCII characters (0-127).
getter/setter pair
base64Reg RegExp
This file contains a regular expression to match ASCII characters.
getter/setter pair
base64RegStr String
A regular expression that matches any string containing only ASCII characters.
getter/setter pair
creditCardReg RegExp
This file contains a regular expression to match ASCII characters.
getter/setter pair
creditCardRegStr String
A regular expression that matches any string containing only ASCII characters.
getter/setter pair
digitReg RegExp
A RegExp object used to validate if a string consists entirely of digits.
getter/setter pair
digitRegStr String
A regular expression pattern that matches strings containing only digits.
getter/setter pair
emailReg RegExp
A compiled RegExp object for validating email addresses using emailRegStr.
final
fiveDigit RegExp
This file contains a regular expression to match ASCII characters. A regular expression that matches any string containing only ASCII characters. The pattern used by the asciiReg regular expression.
getter/setter pair
fiveDigitStr String
The pattern used by the fiveDigit regular expression. The pattern matches any string that contains exactly 5 digits (0-9).
getter/setter pair
floatReg RegExp
This file contains a regular expression to match ASCII characters. A regular expression that matches any string containing only ASCII characters. The pattern used by the asciiReg regular expression.
getter/setter pair
floatRegStr String
The pattern used by the floatReg regular expression. The pattern matches any string that contains a valid floating-point number. The pattern allows for optional leading and trailing digits, an optional decimal point,
getter/setter pair
fourDigit RegExp
This file contains a regular expression to match ASCII characters. A regular expression that matches any string containing only ASCII characters. The pattern used by the asciiReg regular expression. The pattern matches any string that contains only characters in the range 0-127 (inclusive).
getter/setter pair
fourDigitStr String
The pattern used by the fourDigit regular expression. The pattern matches any string that contains exactly 4 digits (0-9). The pattern allows for optional leading and trailing digits, an optional decimal point,
getter/setter pair
fullWidthReg RegExp
This file contains a regular expression to match ASCII characters. A regular expression that matches any string containing only ASCII characters. The pattern used by the asciiReg regular expression.
getter/setter pair
fullWidthRegStr String
The pattern used by the fullWidthReg regular expression. The pattern matches any string that contains only full-width characters. The pattern allows for optional leading and trailing digits, an optional decimal point,
getter/setter pair
halfWidthReg RegExp
This file contains a regular expression to match ASCII characters. A regular expression that matches any string containing only ASCII characters. The pattern used by the asciiReg regular expression. The pattern matches any string that contains only characters in the range 0-127 (inclusive).
getter/setter pair
halfWidthRegStr String
The pattern used by the halfWidthReg regular expression. The pattern matches any string that contains only half-width characters. The pattern allows for optional leading and trailing digits, an optional decimal point, and an optional exponent part (e.g., e+10 or E-10). The pattern matches any string that contains only half-width characters.
getter/setter pair
hexadecimalReg RegExp
This file contains a regular expression to match ASCII characters. A regular expression that matches any string containing only ASCII characters. The pattern used by the asciiReg regular expression. The pattern matches any string that contains only characters in the range 0-127 (inclusive).
getter/setter pair
hexadecimalRegStr String
The pattern used by the hexadecimalReg regular expression. The pattern matches any string that contains only hexadecimal digits (0-9, a-f, A-F). The pattern allows for an optional leading and trailing digits, an optional decimal point, and an optional exponent part (e.g., e+10 or E-10).
getter/setter pair
hexColorReg RegExp
This file contains a regular expression to match ASCII characters. A regular expression that matches any string containing only ASCII characters. The pattern used by the asciiReg regular expression. The pattern matches any string that contains only characters in the range 0-127 (inclusive).
getter/setter pair
hexColorRegStr String
  • The pattern used by the hexColorReg regular expression.
  • The pattern matches any string that contains a valid hexadecimal color code.
  • The pattern allows for an optional leading '#' character, followed by either 3 or 6 hexadecimal digits (0-9, a-f, A-F).
  • getter/setter pair
    intReg RegExp
    This file contains a regular expression to match ASCII characters. A regular expression that matches any string containing only ASCII characters. The pattern used by the asciiReg regular expression.
    getter/setter pair
    intRegStr String
    The pattern used by the intReg regular expression. The pattern matches any string that contains a valid integer. The pattern allows for optional leading and trailing digits, an optional decimal point, and an optional exponent part (e.g., e+10 or E-10). The pattern matches any string that contains only digits (0-9).
    getter/setter pair
    ipv4Maybe RegExp
    This file contains a regular expression to match ASCII characters. A regular expression that matches any string containing only ASCII characters. The pattern used by the asciiReg regular expression. The pattern matches any string that contains only characters in the range 0-127 (inclusive).
    getter/setter pair
    ipv4MaybeStr String
    The pattern used by the ipv4Maybe regular expression. The pattern matches any string that contains a valid IPv4 address. The pattern allows for optional leading and trailing digits, an optional decimal point, and an optional exponent part (e.g., e+10 or E-10).
    getter/setter pair
    ipv6 RegExp
    This file contains a regular expression to match ASCII characters. A regular expression that matches any string containing only ASCII characters. The pattern used by the asciiReg regular expression. The pattern matches any string that contains only characters in the range 0-127 (inclusive).
    getter/setter pair
    ipv6Str String
    The pattern used by the ipv6 regular expression. The pattern matches any string that contains a valid IPv6 address. The pattern allows for optional leading and trailing digits, an optional decimal point, and an optional exponent part (e.g., e+10 or E-10). The pattern matches any string that contains only hexadecimal digits (0-9, a-f, A-F).
    getter/setter pair
    isbn10MaybeReg RegExp
    RegExp instance for validating ISBN-10 format.
    getter/setter pair
    isbn10MaybeRegStr String
    Regular expression string pattern for validating ISBN-10 format.
    getter/setter pair
    isbn13MaybeReg RegExp
    A regular expression that matches exactly 13 digits.
    getter/setter pair
    isbn13MaybeRegStr String
    The pattern used to match exactly 13 numeric digits.
    getter/setter pair
    lowerCaseReg RegExp
    A RegExp object used to validate if a string contains only lowercase letters.
    getter/setter pair
    lowerCaseRegStr String
    A regular expression pattern that matches strings containing only lowercase letters (a–z).
    getter/setter pair
    multiByteReg RegExp
    A regular expression that matches any non-ASCII (multi byte) character.
    getter/setter pair
    multiByteRegStr String
    The pattern used to match non-ASCII characters.
    getter/setter pair
    numericReg RegExp
    A regular expression that matches integer numeric strings, including negatives.
    getter/setter pair
    numericRegStr String
    The pattern used to match whole integer numbers (optionally negative).
    getter/setter pair
    phoneReg RegExp
    A RegExp object used to validate phone numbers using phoneRegStr.
    getter/setter pair
    phoneRegStr String
    A regular expression pattern used to validate international phone numbers.
    getter/setter pair
    postalCodePatterns Map<String, RegExp>
    A map of ISO 3166-1 alpha-2 country codes to their postal code regular expression patterns.
    getter/setter pair
    sixDigit RegExp
    A regular expression that matches exactly 6 digits.
    getter/setter pair
    sixDigitStr String
    The pattern used to match strings that contain exactly six digits.
    getter/setter pair
    specialCharReg RegExp
    A RegExp object used to check if a string contains only special characters.
    getter/setter pair
    specialCharStr String
    A regular expression pattern that matches strings containing only special characters.
    getter/setter pair
    surrogatePairsReg RegExp
    A regular expression that matches UTF-16 surrogate pairs.
    getter/setter pair
    surrogatePairsRegStr String
    The pattern used to match UTF-16 surrogate pairs.
    getter/setter pair
    threeDigit RegExp
    A regular expression that matches exactly 3 digits.
    getter/setter pair
    threeDigitStr String
    The pattern used to match strings that consist of exactly three digits.
    getter/setter pair
    upperCaseReg RegExp
    A RegExp object used to validate if a string contains only uppercase letters.
    getter/setter pair
    upperCaseStr String
    A regular expression pattern that matches strings containing only uppercase letters (A–Z).
    getter/setter pair
    urlReg RegExp
    A RegExp object used to validate basic URL strings using urlStr.
    getter/setter pair
    urlStr String
    A regular expression pattern that matches basic URL formats.
    getter/setter pair
    uuidReg Map<String, RegExp>
    A map of UUID versions (as strings) to their corresponding regular expressions.
    getter/setter pair
    whiteSpaceReg RegExp
    A RegExp object used to validate if a string contains only whitespace characters.
    getter/setter pair
    whiteSpaceStr String
    A regular expression pattern that matches strings containing only whitespace characters.
    getter/setter pair

    Functions

    asFormValidator<TIssue extends ValidationIssue, TValue>({required ValidationResult<TIssue, TValue> validate(String input), required ValidationMessageResolver<TIssue> resolve, String? validatorOverride(String?)?}) String? Function(String?)
    Converts a canonical validator into a Flutter-style form validator.
    contains(String str, String seed) bool
    Checks if the given str contains the substring seed.
    containsIgnoreCase(String str, String seed) bool
    Checks if the given str contains the substring seed, ignoring case.
    isAfter(String? str, [String? date]) bool
    check if the string is a date that's after the specified date
    isAlpha(String str) bool
    check if the string str contains only letters (a-zA-Z).
    isAlphaNumeric(String str) bool
    check if the string str contains only letters and numbers
    isAscii(String str) bool
    check if the string contains ASCII chars only
    isBase64(String str) bool
    check if a string str is base64 encoded
    isBefore(String? str, [String? date]) bool
    check if the string is a date that's before the specified date
    isByteLength(String str, int min, [int? max]) bool
    check if the string's length (in bytes) falls in a range.
    isCreditCard(String str) bool
    Validates whether the given string is a valid credit card number using the Luhn algorithm.
    isDate(String str) bool
    check if the string is a date
    isDivisibleBy(String str, String n) bool
    check if the string str is a number that's divisible by another
    isEmail(String str) bool
    check if the string str is an email
    isFloat(String str) bool
    check if the string str is a float
    isFQDN(String str, {bool requireTld = true, bool allowUnderscores = false}) bool
    Validates if the given string str is a Fully Qualified Domain Name (FQDN).
    isFullWidth(String str) bool
    check if the string contains any full-width chars
    isHalfWidth(String str) bool
    check if the string contains any half-width chars
    isHexadecimal(String str) bool
    check if the string stris a hexadecimal number
    isHexColor(String str) bool
    check if the string str is a hexadecimal color
    isInt(String str) bool
    check if the string str is an integer
    isISBN(String? str, [String? version]) bool
    check if the string is an ISBN (version 10 or 13)
    isJson(String str) bool
    check if the string is valid JSON
    isLength(String str, int min, [int? max]) bool
    check if the length of the string str falls in a range
    isLowerCase(String str) bool
    check if the string str is lowercase
    isMongoId(String str) bool
    check if the string is a valid hex-encoded representation of a MongoDB ObjectId
    isMultiByte(String str) bool
    check if the string contains one or more multi byte chars
    isNull(String? str) bool
    check if the string str is null
    isNumeric(String str) bool
    check if the string str contains only numbers
    isPostalCode(String? text, String locale, {bool orElse()?}) bool
    Checks if the given text matches the postal code pattern for the specified locale.
    isSurrogatePair(String str) bool
    check if the string contains any surrogate pairs chars
    isUpperCase(String str) bool
    check if the string str is uppercase
    isUuid(String? str, [String? version]) bool
    check if the string is a UUID (version 3, 4 or 5).
    isVariableWidth(String str) bool
    check if the string contains a mixture of full and half-width chars
    matches(String str, String pattern) bool
    check if string str matches the pattern.
    resolveEmailValidationIssue(EmailValidationIssue issue) String
    Default English messages for email validation issues.
    resolveNumberValidationIssue(NumberValidationIssue issue) String
    Default English messages for number validation issues.
    resolvePasswordValidationIssue(PasswordValidationIssue issue) String
    Default English messages for password validation issues.
    resolveTextValidationIssue(TextValidationIssue issue) String
    Default English messages for text validation issues.

    Typedefs

    ValidationMessageResolver<TIssue extends ValidationIssue> = String Function(TIssue issue)
    Maps a typed validation issue into a user-facing message.
    ValidationResult<TIssue extends ValidationIssue, TValue> = Either<TIssue, TValue>
    Canonical result shape for validators.