Skip to content

Commit

Permalink
ISBN: Fixed mypy format logic issues
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmucidas committed Dec 29, 2023
1 parent 018d1e1 commit 4f295bf
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pydantic_extra_types/isbn.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ def validate_isbn_digits(value: str) -> None:
validation_functions = {10: isbn10_digit_calc, 13: isbn13_digit_calc}
validate = validation_functions.get(isbn_length)

if not callable(validate):
raise PydanticCustomError('isbn_invalid_length', f'Unsupported ISBN length: {isbn_length}')

if validate(value) != value[-1]:
raise PydanticCustomError('isbn_invalid_digit_check_isbn', 'Provided digit is invalid for given ISBN')

Expand Down

0 comments on commit 4f295bf

Please sign in to comment.