validCountry static method
Implementation
static PhoneNumberInputValidator validCountry(
/// list of valid country isocode
List<IsoCode> expectedCountries, {
/// custom error message
String? errorText,
/// determine whether a missing value should be reported as invalid
bool allowEmpty = true,
}) {
return (PhoneNumber? valueCandidate) {
if (valueCandidate != null &&
(!allowEmpty || valueCandidate.nsn.isNotEmpty) &&
!expectedCountries.contains(valueCandidate.isoCode)) {
return errorText ?? 'invalidCountry';
}
return null;
};
}