username static method
FormFieldValidator that requires the field's value to be a valid username.
Parameters:
minLength
The minimum length of the username (default: 3).maxLength
The maximum length of the username (default: 32).allowNumbers
Whether digits are allowed (default: true).allowUnderscore
Whether underscores are allowed (default: false).allowDots
Whether dots are allowed (default: false).allowDash
Whether dashes are allowed (default: false).allowSpace
Whether spaces are allowed (default: false).allowSpecialChar
Whether special characters are allowed (default: false).errorText
The error message when the username is invalid.checkNullOrEmpty
Whether to check for null or empty values.
Implementation
static FormFieldValidator<String> 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,
}) => UsernameValidator(
minLength: minLength,
maxLength: maxLength,
allowNumbers: allowNumbers,
allowUnderscore: allowUnderscore,
allowDots: allowDots,
allowDash: allowDash,
allowSpace: allowSpace,
allowSpecialChar: allowSpecialChar,
errorText: errorText,
checkNullOrEmpty: checkNullOrEmpty,
).validate;