You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello. I would like to suggest that you implement a length validator, with options to choose from. This may be necessary for some standardized form values, such as INN (which can be either 10 or 12 characters long).
Alternatives you've considered
Not found
Aditional information
class SelectLengthValidator<T> extends TranslatedValidator<T> {
final Set<int> lengthOptions;
const SelectLengthValidator(this.lengthOptions, {
super.errorText,
super.checkNullOrEmpty,
});
@override
String get translatedErrorText => 'The length of the value must be one of the following values: $lengthOptions.';
@override
String? validateValue(T valueCandidate) {
final valueLength = switch (valueCandidate) {
String() => valueCandidate.length,
Iterable() => valueCandidate.length,
Map() => valueCandidate.length,
_ => 0,
};
return !lengthOptions.contains(valueLength) ? errorText : null;
}
}
The text was updated successfully, but these errors were encountered:
Is there an existing issue for this?
Package/Plugin version
11.1.1
What you'd like to happen
Hello. I would like to suggest that you implement a length validator, with options to choose from. This may be necessary for some standardized form values, such as INN (which can be either 10 or 12 characters long).
Alternatives you've considered
Not found
Aditional information
The text was updated successfully, but these errors were encountered: