clean_validator
library
Functions
isAge (String ? value , {int ? minAge , int ? maxAge })
→ bool
Returns true if the value is a valid age.
isAgeFromDate (String ? value , {int ? minAge , int ? maxAge , DateTime ? now })
→ bool
Returns true if the value is a valid birth date and the derived age falls
within the optional bounds.
isAmex (String ? value )
→ bool
Returns true if the value is a valid American Express card number.
isBase ({required String ? value , bool isBase64 = false , bool isBase32 = false , bool isBase58 = false })
→ bool
Returns true if the value is valid for the specified base encoding
isBic (String ? value )
→ bool
Returns true if the BIC/SWIFT code is valid
isContains (String ? value , String substring )
→ bool
Returns true if the value contains the given substring
isCoordinate (String ? latitude , String ? longitude )
→ bool
Returns true if both latitude and longitude strings are valid
isCoordinateString (String ? value )
→ bool
Returns true if the coordinate string in format "lat,lng" or "lat lng" is valid
isCreditCardCvc (String ? value )
→ bool
Returns true if the CVC is valid
isCreditCardExpiry (String ? value )
→ bool
Returns true if the expiry date is valid (MM/YY format and not expired)
isCreditCardNumber (String ? value , {bool visa = true , bool mastercard = true , bool amex = true , bool discover = true , bool jcb = true , bool diners = true })
→ bool
Returns true if the value is a valid credit card number.
Accepts spaces and dashes as formatting characters.
By default all networks are enabled. Set any to false to restrict
which networks are accepted.
isDiners (String ? value )
→ bool
Returns true if the value is a valid Diners Club card number.
isDiscover (String ? value )
→ bool
Returns true if the value is a valid Discover card number.
isEmail (String ? value )
→ bool
Returns true if the email is valid
isEndsWith (String ? value , String suffix )
→ bool
Returns true if the value ends with the given suffix
isEqual (dynamic value , dynamic compareTo )
→ bool
Returns true if the value equals the comparison value
isHexadecimal (String ? value )
→ bool
Returns true if the value is a valid hexadecimal string
isHexColor (String ? value )
→ bool
Returns true if the value is a valid hex color string
isIban (String ? value )
→ bool
Returns true if the IBAN is valid (basic format validation)
isIP (String ? value , {bool iPv4 = true , bool iPv6 = true })
→ bool
Returns true if the value is a valid IP address.
By default both iPv4 and iPv6 are enabled.
Set either to false to restrict which formats are accepted.
isIPv4 (String ? value )
→ bool
Returns true if the value is a valid IPv4 address
isIPv6 (String ? value )
→ bool
Returns true if the value is a valid IPv6 address
isIsbn (String ? value )
→ bool
Returns true if the ISBN is valid (supports ISBN-10 and ISBN-13)
isJCB (String ? value )
→ bool
Returns true if the value is a valid JCB card number.
isJson (String ? value )
→ bool
Returns true if the value is a valid JSON string.
isJsonArray (String ? value )
→ bool
Returns true if the value is a valid JSON array [ ].
isJsonObject (String ? value )
→ bool
Returns true if the value is a valid JSON object { }.
isLatitude (String ? value )
→ bool
Returns true if the latitude is valid (-90 to 90)
isLength (dynamic value , {int ? minLength , int ? maxLength })
→ bool
Returns true if the value meets the length constraints.
At least one of minLength or maxLength must be provided.
isLongitude (String ? value )
→ bool
Returns true if the longitude is valid (-180 to 180)
isMacAddress (String ? value , {bool allowDot = true })
→ bool
Returns true if the value is a valid MAC address.
Accepts colon-separated (00:1A:2B:3C:4D:5E) and
hyphen-separated (00-1A-2B-3C-4D-5E) notation.
Set allowDot to false to reject Cisco dot notation (0012.3AB3.4D5E).
isMastercard (String ? value )
→ bool
Returns true if the value is a valid Mastercard number.
isMaxWordsCount (String ? value , int maxWords )
→ bool
Returns true if the value has at most the maximum number of words
isMinWordsCount (String ? value , int minWords )
→ bool
Returns true if the value has at least the minimum number of words
isNotNull (String ? value )
→ bool
Returns true if the value is not null
isPassword (String ? value , List <PasswordRule > rules )
→ bool
isPresent (String ? value )
→ bool
Returns true if the value is present (not null, not empty or whitespace)
isRequired (dynamic value , {bool trim = true })
→ bool
Returns true if the value is not null and not empty
isStartsWith (String ? value , String prefix )
→ bool
Returns true if the value starts with the given prefix
isUrl (String ? value )
→ bool
Returns true if the URL is valid
isUUID (String ? value , {bool v1 = true , bool v2 = true , bool v3 = true , bool v4 = true , bool v5 = true })
→ bool
Returns true if the value is a valid UUID.
By default all versions v1, v2, v3, v4, v5 are enabled.
Set any to false to restrict which versions are accepted.
isUUIDv1 (String ? value )
→ bool
Returns true if the value is a valid UUID v1
isUUIDv2 (String ? value )
→ bool
Returns true if the value is a valid UUID v2
isUUIDv3 (String ? value )
→ bool
Returns true if the value is a valid UUID v3
isUUIDv4 (String ? value )
→ bool
Returns true if the value is a valid UUID v4
isUUIDv5 (String ? value )
→ bool
Returns true if the value is a valid UUID v5
isValidRegex (String ? value , {required String pattern })
→ bool
Returns true if the value matches the given pattern.
isVisa (String ? value )
→ bool
Returns true if the value is a valid Visa card number.
validateAge ({int ? minAge , int ? maxAge , String ? failMessage })
→ String ? Function(dynamic )
Returns error message if invalid, null if valid.
validateAgeFromDate ({int ? minAge , int ? maxAge , String ? failMessage , DateTime ? now })
→ String ? Function(dynamic )
Returns error message if invalid, null if valid.
validateBase ({bool isBase64 = false , bool isBase32 = false , bool isBase58 = false , String ? failMessage })
→ String ? Function(dynamic )
Returns error message if not valid base encoding, null if valid
validateBase32 ({String ? failMessage })
→ String ? Function(dynamic )
validateBase58 ({String ? failMessage })
→ String ? Function(dynamic )
validateBase64 ({String ? failMessage })
→ String ? Function(dynamic )
Convenience validators for specific base formats
validateBic ({String ? failMessage })
→ String ? Function(dynamic )
Returns error message if invalid, null if valid
validateContains ({required String substring , String ? failMessage })
→ String ? Function(dynamic )
Returns error message if doesn't contain substring, null if valid
validateCoordinatePair (String ? latitude , String ? longitude , {String ? failMessage })
→ String ?
Validates both latitude and longitude manually (not a form field validator).
Returns null if valid, or an error message describing which field is invalid.
validateCoordinateString ({String ? failMessage })
→ String ? Function(dynamic )
Returns error message if invalid, null if valid (validates combined "lat,lng" string)
validateCreditCardCvc ({String ? failMessage })
→ String ? Function(dynamic )
Returns error message if invalid, null if valid
validateCreditCardExpiry ({String ? failMessage })
→ String ? Function(dynamic )
Returns error message if invalid, null if valid
validateCreditCardNumber ({String ? failMessage , bool visa = true , bool mastercard = true , bool amex = true , bool discover = true , bool jcb = true , bool diners = true })
→ String ? Function(dynamic )
Returns error message if invalid, null if valid.
Accepts spaces and dashes as formatting characters.
By default all networks are enabled. Set any to false to restrict
which networks are accepted.
validateCustom (bool predicate (dynamic ), {String ? failMessage })
→ String ? Function(dynamic )
Returns error message if predicate returns false, null if valid
validateEmail ({String ? failMessage })
→ String ? Function(dynamic )
Returns error message if invalid, null if valid
validateEndsWith ({required String suffix , String ? failMessage })
→ String ? Function(dynamic )
Returns error message if doesn't end with suffix, null if valid
validateEqual (dynamic compareTo , {String ? failMessage })
→ String ? Function(dynamic )
Returns error message if values don't match, null if valid
validateHexadecimal ({String ? failMessage })
→ String ? Function(dynamic )
Returns error message if not valid hexadecimal, null if valid
validateHexColor ({String ? failMessage })
→ String ? Function(dynamic )
Returns error message if not valid hex color, null if valid
validateIban ({String ? failMessage })
→ String ? Function(dynamic )
Returns error message if invalid, null if valid
validateIP ({String ? failMessage , bool iPv4 = true , bool iPv6 = true })
→ String ? Function(dynamic )
Returns error message if invalid, null if valid.
By default both iPv4 and iPv6 are enabled.
Set either to false to restrict which formats are accepted.
validateIsbn ({String ? failMessage })
→ String ? Function(dynamic )
Returns error message if invalid, null if valid
validateIsPresent ({String ? failMessage })
→ String ? Function(dynamic )
Returns error message if not present, null if valid
validateJson ({String ? failMessage , bool object = false , bool array = false })
→ String ? Function(dynamic )
Returns error message if invalid, null if valid.
Use object or array to restrict the expected JSON structure.
Enabling both object and array accepts either structure.
validateLatitude ({String ? failMessage })
→ String ? Function(dynamic )
Returns error message if invalid, null if valid
validateLength ({String ? failMessage , int ? minLength , int ? maxLength })
→ String ? Function(dynamic )
Returns a validator function that checks length constraints.
At least one of minLength or maxLength must be provided.
validateLongitude ({String ? failMessage })
→ String ? Function(dynamic )
Returns error message if invalid, null if valid
validateMacAddress ({String ? failMessage , bool allowDot = true })
→ String ? Function(dynamic )
Returns error message if invalid, null if valid.
Set allowDot to false to reject Cisco dot notation (0012.3AB3.4D5E).
validateMaxWordsCount ({required int maxWords , String ? failMessage })
→ String ? Function(dynamic )
Returns error message if word count exceeds maximum, null if valid
validateMinWordsCount ({required int minWords , String ? failMessage })
→ String ? Function(dynamic )
Returns error message if word count is below minimum, null if valid
validateNotNull ({String ? failMessage })
→ String ? Function(dynamic )
Returns error message if null, null if valid
validatePassword ({required List <PasswordRule > rules })
→ String ? Function(dynamic )
Returns a validator function for passwords.
rules is a list of PasswordRule classes to be enforced.
minLength and maxLength are optional length constraints.
validateRegex ({required String pattern , String ? failMessage })
→ String ? Function(dynamic )
Returns error message if the value does not match pattern, null if valid.
validateRequired ({String ? failMessage , bool trim = true })
→ String ? Function(dynamic )
Returns error message if null or empty, null if valid
validateStartsWith ({required String prefix , String ? failMessage })
→ String ? Function(dynamic )
Returns error message if doesn't start with prefix, null if valid
validateUrl ({String ? failMessage })
→ String ? Function(dynamic )
Returns error message if invalid, null if valid
validateUUID ({String ? failMessage , bool v1 = true , bool v2 = true , bool v3 = true , bool v4 = true , bool v5 = true })
→ String ? Function(dynamic )
Returns error message if invalid, null if valid.
By default all versions v1, v2, v3, v4, v5 are enabled.
Set any to false to restrict which versions are accepted.