ISBN constructor
ISBN(
- String? str
Returns a valid ISBN object.
Throws ValueException:
- RequiredValueException if
str
is null or empty. - InvalidValueException if
str
is not a valid ISBN number.
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.');
}