validCountry static method
PhoneNumberInputValidator
validCountry(
- BuildContext context,
- List<
IsoCode> expectedCountries, { - String? errorText,
Implementation
static PhoneNumberInputValidator validCountry(
BuildContext context,
/// list of valid country isocode
List<IsoCode> expectedCountries, {
/// custom error message
String? errorText,
}) {
return (PhoneNumber? valueCandidate) {
if (valueCandidate != null &&
(valueCandidate.nsn.isNotEmpty) &&
!expectedCountries.contains(valueCandidate.isoCode)) {
return errorText ?? PhoneFieldLocalization.of(context).invalidCountry;
}
return null;
};
}