validatePhone method

String validatePhone(
  1. String? phone
)

Implementation

String validatePhone(String? phone) {
  String input = (phone ?? '').trim();

  if (input.isEmpty || !RegExp(RegexPattern.phone).hasMatch(input)) {
    throw Exception('Invalid Phone');
  }

  return input;
}