validCountry static method

PhoneNumberInputValidator validCountry(
  1. BuildContext context,
  2. List<IsoCode> expectedCountries, {
  3. 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;
  };
}