abstract class PhoneValidator {
  static String? validate(String? phoneNumber, {bool isRequired = true}) {
    // Regular expression for validating phone numbers
    final RegExp phoneRegExp = RegExp(r'^\+?[1-9]\d{1,14}$');

    if (isRequired && (phoneNumber==null || phoneNumber.isEmpty)) {
      return 'Phone number is required';
    } else if (phoneNumber !=null && !phoneRegExp.hasMatch(phoneNumber)) {
      return 'Invalid phone number';
    }
    return null;
  }
}