valid static method

PhoneNumberInputValidator valid({
  1. String? errorText,
  2. bool allowEmpty = true,
})

Implementation

static PhoneNumberInputValidator valid({
  /// 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) {
      return errorText ?? 'invalidPhoneNumber';
    }
    if (valueCandidate != null && (!allowEmpty || valueCandidate.nsn.isNotEmpty) && !valueCandidate.isValid()) {
      return errorText ?? 'invalidPhoneNumber';
    }
    return null;
  };
}