Skip to main content
Pydantic Docs
current

Search documentation

Type to search this documentation.

On this pageOverview

ISBN

The pydantic_extra_types.isbn module provides functionality to receive and validate ISBN.

ISBN (International Standard Book Number) is a numeric commercial book identifier which is intended to be unique. This module provides an ISBN type for Pydantic models.

Bases: str

Represents a ISBN and provides methods for conversion, validation, and serialization.

Python
from pydantic import BaseModel

from pydantic_extra_types.isbn import ISBN

class Book(BaseModel):
    isbn: ISBN

book = Book(isbn='8537809667')
print(book)
# > isbn='9788537809662'

@staticmethod

Python
def validate_isbn_format(value: str) -> None

Validate a ISBN format from the provided str value.

None

value : str

The str value representing the ISBN in 10 or 13 digits.

  • PydanticCustomError -- If the ISBN is not valid.

@staticmethod

Python
def convert_isbn10_to_isbn13(value: str) -> str

Convert an ISBN-10 to ISBN-13.

str -- The converted ISBN or the original value if no conversion is necessary.

value : str

The ISBN-10 value to be converted.

Python
def isbn10_digit_calc(isbn: str) -> str

Calculate the ISBN-10 check digit from the provided str value. More information on the validation algorithm on Wikipedia

str -- The calculated last digit of the ISBN-10 value.

isbn : str

The str value representing the ISBN in 10 digits.

Python
def isbn13_digit_calc(isbn: str) -> str

Calc a ISBN-13 last digit from the provided str value. More information on the validation algorithm on Wikipedia

str -- The calculated last digit of the ISBN-13 value.

isbn : str

The str value representing the ISBN in 13 digits.

Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu