phone method

ValidatorFn<String> phone([
  1. String? message
])

A phone validator.

Implementation

ValidatorFn<String> phone([String? message]) {
  return (String? value, BuildContext context) {
    if (value == null || value.isEmpty) {
      return this.call(value, context);
    }

    if (!_phonePattern.hasMatch(value)) {
      return message ?? HookFormScope.of(context).invalidPhone;
    }

    return this.call(value, context);
  };
}