FormValidator class
Constructors
FormValidator ({dynamic data , String ? attribute })
Create a new form validator with message and data
FormValidator.beginsWith (String prefix , {String ? message })
Validate that the value begins with prefix
message The message to display if the value is invalid
FormValidator.booleanFalse ({String ? message })
Validate a value is a boolean
message The message to display if the value is invalid
FormValidator.booleanTrue ({String ? message })
Validate a value is a boolean
message The message to display if the value is invalid
FormValidator.capitalized ({String ? message })
Validate that the value is capitalized
message The message to display if the value is invalid
FormValidator.contains (List <String > values , {String ? message })
Validate the value contains one of the values
message The message to display if the value is invalid
FormValidator.custom ({String ? message , required bool validate (dynamic data ) })
Validate a custom rule
message The message to display if the custom validation fails
validate The custom validation function that takes the data and returns a boolean
FormValidator.date ({String ? message })
Validate that the value is a date
message The message to display if the value is invalid
FormValidator.dateAgeIsOlder (int age , {String ? message })
Validate that the date is older than age
message The message to display if the value is invalid
age The age to compare
FormValidator.dateAgeIsYounger (int age , {String ? message })
Validate that the date is younger than age
message The message to display if the value is invalid
age The age to compare
FormValidator.dateInFuture ({String ? message })
Validate that the date is in the future
message The message to display if the value is invalid
FormValidator.dateInPast ({String ? message })
Validate that the date is in the past
message The message to display if the value is invalid
FormValidator.email ({String ? message })
Validate an email
message The message to display if the email is invalid
FormValidator.endsWith (String suffix , {String ? message })
Validate that the value ends with suffix
message The message to display if the value is invalid
FormValidator.lowercase ({String ? message })
Validate that the value is lowercase
message The message to display if the value is invalid
FormValidator.maxLength (int value , {String ? message })
Validate that the value is a maximum of value characters
message The message to display if the value is invalid
value The maximum number of characters
FormValidator.maxSize (int value , {String ? message })
Validate that the value is a maximum size of value
message The message to display if the value is invalid
value The maximum size
FormValidator.maxValue (int value , {String ? message })
Validate that the value is a maximum of value
message The message to display if the value is invalid
value The maximum value
FormValidator.minLength (int value , {String ? message })
Validate that the value is a minimum of value characters
message The message to display if the value is invalid
value The minimum number of characters
FormValidator.minSize (int value , {String ? message })
Validate that the value is a minimum size of value
message The message to display if the value is invalid
value The minimum size
FormValidator.minValue (int value , {String ? message })
Validate that the value is a minimum of value
message The message to display if the value is invalid
value The minimum value
FormValidator.notEmpty ({String ? message })
Validate that the value is not empty
message The message to display if the value is invalid
FormValidator.numeric ({String ? message })
Validate that the value is numeric
message The message to display if the value is invalid
FormValidator.password ({int strength = 1 , String ? message })
Validate a password with a strength of 1 or 2
strength 1: 1 uppercased letter, 1 digit, 8 characters
strength 2: 1 uppercased letter, 1 digit, 1 special character, 8 characters
message The message to display if the password is invalid
FormValidator.phoneNumberUk ({String ? message })
Validate a UK phone number
message The message to display if the phone number is invalid
FormValidator.phoneNumberUs ({String ? message })
Validate a US phone number
message The message to display if the phone number is invalid
FormValidator.postcodeUk ({String ? message })
Validate that the value is a valid postcode for the UK
message The message to display if the value is invalid
FormValidator.regex (String regex , {String ? message })
Validate that the value matches a regex pattern
message The message to display if the value is invalid
FormValidator.rule (List <FormRule > rules , {dynamic data })
Create a new form validator with rules
FormValidator.uppercase ({String ? message })
Validate that the value is uppercase
message The message to display if the value is invalid
FormValidator.url ({String ? message })
Validate a URL
message The message to display if the URL is invalid
FormValidator.zipcodeUs ({String ? message })
Validate that the value is a valid zipcode for the US
message The message to display if the value is invalid
Methods
beginsWith (String prefix , {String ? message })
→ FormValidator
Validate that the value begins with prefix
booleanFalse ({String ? message })
→ FormValidator
Validate a value is a boolean (must be false)
booleanTrue ({String ? message })
→ FormValidator
Validate a value is a boolean
capitalized ({String ? message })
→ FormValidator
Validate that the value is capitalized
check ([dynamic data ])
→ FormValidationResult
Check the validation of the data against the rules
Returns a FormValidationResponse indicating success or error
contains (List <String > values , {String ? message })
→ FormValidator
Validate the value contains one of the values
custom ({String ? message , required bool validate (dynamic data ) })
→ FormValidator
Validate a custom rule
message The message to display if the custom validation fails
validate The custom validation function that takes the data and returns a boolean
date ({String ? message })
→ FormValidator
Validate that the value is a date
dateAgeIsOlder (int age , {String ? message })
→ FormValidator
Validate that the date is older than age
dateAgeIsYounger (int age , {String ? message })
→ FormValidator
Validate that the date is younger than age
dateInFuture ({String ? message })
→ FormValidator
Validate that the date is in the future
dateInPast ({String ? message })
→ FormValidator
Validate that the date is in the past
email ({String ? message })
→ FormValidator
Validate an email
endsWith (String suffix , {String ? message })
→ FormValidator
Validate that the value ends with suffix
equals (dynamic data , {String ? message })
→ FormValidator
Validate that the value equals another value
lowercase ({String ? message })
→ FormValidator
Validate that the value is lowercase
maxLength (int value , {String ? message })
→ FormValidator
Validate that the value is a maximum of value characters
maxSize (int value , {String ? message })
→ FormValidator
Validate that the value is a maximum size of value
maxValue (int value , {String ? message })
→ FormValidator
Validate that the value is a maximum of value
minLength (int value , {String ? message })
→ FormValidator
Validate that the value is a minimum of value characters
minSize (int value , {String ? message })
→ FormValidator
Validate that the value is a minimum size of value
minValue (int value , {String ? message })
→ FormValidator
Validate that the value is a minimum of value
noSuchMethod (Invocation invocation )
→ dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notEmpty ({String ? message })
→ FormValidator
Validate that the value is not empty
numeric ({String ? message })
→ FormValidator
Validate that the value is numeric
password ({required int strength , String ? message })
→ FormValidator
Validate that the value is a password
phoneNumberUk ({String ? message })
→ FormValidator
Validate a UK phone number
phoneNumberUs ({String ? message })
→ FormValidator
Validate a US phone number
postcodeUk ({String ? message })
→ FormValidator
Validate that the value is a valid postcode for the UK
regex (String regex , {String ? message })
→ FormValidator
Validate that the value matches a regex pattern
setAttribute (String ? attribute )
→ void
Sets the attribute name for error messages.
setData (dynamic data )
→ void
Set the data for the form validator
toString ()
→ String
A string representation of this object.
inherited
uppercase ({String ? message })
→ FormValidator
Validate that the value is uppercase
url ({String ? message })
→ FormValidator
Validate a URL
zipcodeUs ({String ? message })
→ FormValidator
Validate that the value is a valid zipcode for the US