validatePhoneNumberByContry static method
Validate a phone number based on the country
Implementation
static bool validatePhoneNumberByContry(String phoneNumber, Country country) {
int length = phoneNumber.length;
bool lengthValid =
length >= country.phoneMinLength && length <= country.phoneMaxLength;
bool startingDigitsValid = country.startingDigits.isEmpty ||
country.startingDigits.any((digits) => phoneNumber.startsWith(digits));
return lengthValid && startingDigitsValid;
}