ISBN constructor

ISBN(
  1. String? str
)

Returns a valid ISBN object.

Throws ValueException:

Implementation

factory ISBN(String? str) {
  if (str == null || str.isEmpty) {
    throw const RequiredValueException();
  } else if (isISBN(str, '10')) {
    return ISBN._(str, ISBNVersion.v10);
  } else if (isISBN(str, '13')) {
    return ISBN._(str, ISBNVersion.v13);
  }
  throw InvalidValueException(str, message: 'Invalid ISBN number.');
}