PhoneNumber constructor

PhoneNumber(
  1. String? str
)

Returns a valid PhoneNumber object.

Throws ValueException:

Implementation

factory PhoneNumber(String? str) {
  if (str == null || str.isEmpty) {
    throw const RequiredValueException();
  }

  if (validate(str)) {
    return PhoneNumber._(str);
  }

  throw InvalidValueException(str, message: 'Invalid phone number.');
}