isbn_validate#

isbn_validate(value, *, version=None)#

Checks whether the value is a valid ISBN.

This function checks whether the specified value is a formally valid ISBN. It does not check whether the ISBN has actually been assigned or is associated with a resource.

Added in version 0.3.0.

Parameters:
valuestr

The value to be checked.

version{‘ISBN-13’, ‘ISBN-10’}

Restriction to a specific ISBN version to be checked. If no version is selected, both ISBNs in the ISBN-13 format and ISBN-10 format are accepted.

Returns:
bool

Returns True if the given value is valid, otherwise False.

Raises:
ValueError

If the version is invalid.

Examples

>>> from marc21_learn.pid import isbn_validate
>>>
>>> isbn_validate("978-3-10-031815-2")
True
>>> isbn_validate("3-10-031815-3")
True

The following ISBN is invalid because the check digit is incorrect.

>>> isbn_validate("9783100318153")
False