validType static method
PhoneNumberInputValidator
validType(
- BuildContext context,
- PhoneNumberType expectedType, {
- String? errorText,
Implementation
static PhoneNumberInputValidator validType(
BuildContext context,
/// expected phonetype
PhoneNumberType expectedType, {
/// custom error message
String? errorText,
}) {
return (PhoneNumber? valueCandidate) {
if (valueCandidate != null &&
valueCandidate.nsn.isNotEmpty &&
!valueCandidate.isValid(type: expectedType)) {
if (expectedType == PhoneNumberType.mobile) {
return errorText ??
PhoneFieldLocalization.of(context).invalidMobilePhoneNumber;
} else if (expectedType == PhoneNumberType.fixedLine) {
return errorText ??
PhoneFieldLocalization.of(context).invalidFixedLinePhoneNumber;
}
return errorText ??
PhoneFieldLocalization.of(context).invalidPhoneNumber;
}
return null;
};
}