import 'package:easy_localization/easy_localization.dart';

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'.tr();
    } else if (phoneNumber !=null && !phoneRegExp.hasMatch(phoneNumber)) {
      return 'invalid_phone_number'.tr();
    }
    return null;
  }
}