isPhoneVietNamValid function

bool isPhoneVietNamValid(
  1. String value
)

Implementation

bool isPhoneVietNamValid(String value) {
  late RegExp rex;
  if (value.length > 2 && value.substring(0, 2) == '84') {
    rex = RegExp(r'(84|0[3|5|7|8|9])+([0-9]{9})\b');
  } else {
    rex = RegExp(r'(84|0[3|5|7|8|9])+([0-9]{8})\b');
  }
  String? result = rex.firstMatch(value)?.input;
  return result != null;
}