FormBuilderValidators class

Provides utility methods for creating various FormFieldValidators.

Constructors

FormBuilderValidators.new()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

aggregate<T>(List<FormFieldValidator<T>> validators) FormFieldValidator<T>
FormFieldValidator that runs validators and collects all error messages.
alphabetical({RegExp? regex, String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to contain only alphabetical characters.
base64({String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid base64 string.
between<T>(num min, num max, {String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<T>
FormFieldValidator that requires the field's value to be between two numbers.
bic({RegExp? regex, String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid BIC.
city({RegExp? regex, List<String> citiesWhitelist = const <String>[], List<String> citiesBlacklist = const <String>[], String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid city.
colorCode({List<String> formats = const <String>['hex', 'rgb', 'hsl'], RegExp? regex, String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid color code.
compose<T>(List<FormFieldValidator<T>> validators) FormFieldValidator<T>
FormFieldValidator that combines multiple validators into one. This validator applies each provided validator sequentially, and fails if any of them return a non-null result.
conditional<T>(bool condition(T? value), FormFieldValidator<T> validator) FormFieldValidator<T>
FormFieldValidator that applies another validator conditionally.
contains(String substring, {bool caseSensitive = true, String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to contain a specific value.
containsElement<T>(List<T> values, {String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<T>
FormFieldValidator that requires the field's value to be in a list of values.
country({List<String> countryWhitelist = const <String>[], List<String> countryBlacklist = const <String>[], String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid country.
creditCard({String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid credit card number.
creditCardCVC({String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid credit card CVC.
creditCardExpirationDate({bool checkForExpiration = true, RegExp? regex, String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid credit card expiration date.
date({String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid date string.
dateFuture({String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be in the future.
datePast({String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid time in the past.
dateRange(DateTime minDate, DateTime maxDate, {String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a date within a certain range.
dateTime({String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<DateTime?>
FormFieldValidator that requires the field's value to be a valid date.
defaultValue<T>(T defaultValue, FormFieldValidator<T> validator) FormFieldValidator<T>
FormFieldValidator that transforms the value to a default if it's null or empty before running the validator.
duns({RegExp? regex, String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid DUNS number.
email({RegExp? regex, String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid email address.
endsWith(String suffix, {String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to end with a specific value.
equal<T>(Object value, {String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<T>
FormFieldValidator that requires the field's value be equal to the provided value.
equalLength<T>(int length, {bool allowEmpty = false, String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<T>
FormFieldValidator that requires the length of the field to be equal to the provided length. Works with String, iterable, and int types.
evenNumber({String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be an even number.
fileExtension(List<String> allowedExtensions, {String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to a valid file extension.
fileName({RegExp? regex, String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid file name.
fileSize(int maxSize, {bool base1024Conversion = true, String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that restricts the size of a file to be less than or equal to the provided maximum size.
firstName({RegExp? regex, List<String> firstNameWhitelist = const <String>[], List<String> firstNameBlacklist = const <String>[], String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid first name.
float<T>({String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<T>
FormFieldValidator that requires the field's value to be a valid float.
hasLowercaseChars({int atLeast = 1, RegExp? regex, String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to contain a minimum number of lowercase characters.
hasNumericChars({int atLeast = 1, RegExp? regex, String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to contain a minimum number of numeric characters.
hasSpecialChars({int atLeast = 1, RegExp? regex, String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to contain a minimum number of special characters.
hasUppercaseChars({int atLeast = 1, RegExp? regex, String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to contain a minimum number of uppercase characters.
hexadecimal({String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid hexadecimal.
iban({RegExp? regex, String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid IBAN.
integer({int? radix, String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the value to be a valid integer.
ip({int version = 4, RegExp? regex, String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid IP address.
isbn({String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid ISBN.
isFalse({String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<bool>
FormFieldValidator that requires the field's value to be a bool and false.
isTrue({String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<bool>
FormFieldValidator that requires the field's value to be a bool and true.
json({String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be valid JSON.
languageCode({RegExp? regex, List<String> languageCodeWhitelist = const <String>[], List<String> languageCodeBlacklist = const <String>[], String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid language code.
lastName({RegExp? regex, List<String> lastNameWhitelist = const <String>[], List<String> lastNameBlacklist = const <String>[], String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid last name.
latitude({String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid latitude.
licensePlate({RegExp? regex, List<String> licensePlateWhitelist = const <String>[], List<String> licensePlateBlacklist = const <String>[], String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid license plate.
log<T>({String log(T? value)?, String? errorText}) FormFieldValidator<T>
FormFieldValidator that logs the value at a specific point in the validation chain. This validator logs the value being validated and always returns null.
longitude({String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid longitude.
lowercase({String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be lowercase.
macAddress({RegExp? regex, String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid MAC address.
match(RegExp regex, {String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to match the provided regex pattern.
matchNot(RegExp regex, {String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value not to match the provided regex pattern.
max<T>(num max, {bool inclusive = true, String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<T>
FormFieldValidator that requires the field's value to be less than (or equal) to the provided number.
maxLength<T>(int maxLength, {String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<T>
FormFieldValidator that requires the length of the field's value to be less than or equal to the provided maximum length.
maxWordsCount(int maxWordsCount, {String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the word count of the field's value to be less than or equal to the provided maximum count.
mimeType({RegExp? regex, String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid MIME type. The MIME type should be in the format type/subtype.
min<T>(num min, {bool inclusive = true, String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<T>
FormFieldValidator that requires the field's value to be greater than (or equal) to the provided number.
minLength<T>(int minLength, {String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<T>
FormFieldValidator that requires the length of the field's value to be greater than or equal to the provided minimum length.
minWordsCount(int minWordsCount, {String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the word count of the field's value to be greater than or equal to the provided minimum count.
negativeNumber<T>({String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<T>
FormFieldValidator that requires the field's value to be a negative number.
notEqual<T>(Object value, {String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<T>
FormFieldValidator that requires the field's value be not equal to the provided value.
notZeroNumber<T>({String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<T>
FormFieldValidator that requires the field's value to be a number that is not zero.
numeric<T>({String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<T>
FormFieldValidator that requires the field's value to be a valid number.
oddNumber({String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be an odd number.
or<T>(List<FormFieldValidator<T>> validators) FormFieldValidator<T>
FormFieldValidator that combines multiple validators, passing validation if any return null.
passport({RegExp? regex, List<String> passportNumberWhitelist = const <String>[], List<String> passportNumberBlacklist = const <String>[], String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid passport number.
password({int minLength = 8, int maxLength = 32, int minUppercaseCount = 1, int minLowercaseCount = 1, int minNumberCount = 1, int minSpecialCharCount = 1, String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid password.
path({String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid file or folder path.
phoneNumber({RegExp? regex, String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid phone number.
portNumber({int min = 0, int max = 65535, String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid port number.
positiveNumber<T>({String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<T>
FormFieldValidator that requires the field's value to be a positive number.
primeNumber<T>({String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<T>
FormFieldValidator that requires the field's value to be a valid prime number.
range<T>(num min, num max, {bool inclusive = true, String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<T>
FormFieldValidator that requires the field's value to be within a certain range.
required<T>({String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<T>
FormFieldValidator that requires the field have a non-empty value.
singleLine({String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a single line.
skipWhen<T>(bool condition(T? value), FormFieldValidator<T> validator) FormFieldValidator<T>
FormFieldValidator that skips the validation when a certain condition is met.
ssn({String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid SSN (Social Security Number).
startsWith(String prefix, {String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to start with a specific value.
state({RegExp? regex, List<String> stateWhitelist = const <String>[], List<String> stateBlacklist = const <String>[], String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid state.
street({RegExp? regex, List<String> streetWhitelist = const <String>[], List<String> streetBlacklist = const <String>[], String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid street address.
time({String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid time.
timeZone({List<String>? validTimeZones, String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid time zone.
transform<T>(T transformer(T? value), FormFieldValidator<T> validator) FormFieldValidator<T>
FormFieldValidator that transforms the value before applying the validator.
unique<T>(List<T> values, {String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<T>
FormFieldValidator that checks if the value is unique in a list of values.
uppercase({String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be uppercase.
url({List<String> protocols = const <String>['http', 'https', 'ftp'], bool requireTld = true, bool requireProtocol = false, bool allowUnderscore = false, List<String> hostWhitelist = const <String>[], List<String> hostBlacklist = const <String>[], RegExp? regex, String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid URL.
username({int minLength = 3, int maxLength = 32, bool allowNumbers = true, bool allowUnderscore = false, bool allowDots = false, bool allowDash = false, bool allowSpace = false, bool allowSpecialChar = false, String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid username.
uuid({String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid UUID.
vin({RegExp? regex, List<String> vinWhitelist = const <String>[], List<String> vinBlacklist = const <String>[], String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid VIN.
zipCode({String? errorText, bool checkNullOrEmpty = true}) FormFieldValidator<String>
FormFieldValidator that requires the field's value to be a valid zip code.