{"id":1414,"library":"checkdigit","title":"checkdigit: Check Digit Library for Data Validation","description":"checkdigit is a Python library providing algorithms for various check digit standards, facilitating data validation and error detection. It supports algorithms like Luhn, ISBN, UPC, EAN, ISIN, Modulo 10, Modulo 11, GS1, and CRC. The current version is 0.5.0, with releases occurring periodically to introduce new features, fix bugs, and refine existing algorithms.","status":"active","version":"0.5.0","language":"en","source_language":"en","source_url":"https://github.com/harens/checkdigit","tags":["checkdigit","validation","data quality","checksum","luhn","isbn","upc","ean","isin","mod10","mod11","gs1","crc"],"install":[{"cmd":"pip install checkdigit","lang":"bash","label":"Install latest stable version"}],"dependencies":[],"imports":[{"note":"Import specific algorithm modules (e.g., luhn, isbn, upc) directly from the top-level package.","symbol":"luhn","correct":"from checkdigit import luhn"},{"note":"As of v0.3.0, dedicated isbn10 and isbn13 functions were removed. Use the unified `isbn` module.","wrong":"from checkdigit.formats import isbn10, isbn13","symbol":"isbn","correct":"from checkdigit import isbn"},{"symbol":"gs1","correct":"from checkdigit import gs1"}],"quickstart":{"code":"from checkdigit import luhn\nfrom checkdigit import isbn\n\n# Validate a number using the Luhn algorithm\nis_valid_luhn = luhn.validate(\"79927398713\")\nprint(f\"'79927398713' is valid Luhn: {is_valid_luhn}\")\n\n# Generate a check digit for a number\nluhn_with_check = luhn.generate(\"7992739871\")\nprint(f\"'7992739871' with Luhn check digit: {luhn_with_check}\")\n\n# Validate an ISBN (supports both ISBN-10 and ISBN-13)\nis_valid_isbn = isbn.validate(\"978-3-16-148410-0\")\nprint(f\"'978-3-16-148410-0' is valid ISBN: {is_valid_isbn}\")\n","lang":"python","description":"This quickstart demonstrates how to import and use the `luhn` and `isbn` modules to validate and generate check digits. The `isbn` module automatically handles both ISBN-10 and ISBN-13 formats."},"warnings":[{"fix":"Migrate usage from `checkdigit.formats.isbn10` or `checkdigit.formats.isbn13` to `checkdigit.isbn.validate()` or `checkdigit.isbn.generate()`. The unified `isbn` module automatically detects the ISBN type.","message":"The separate ISBN-10 and ISBN-13 validation/generation functions (e.g., `isbn10`, `isbn13`) were removed. All ISBN operations are now handled by a single `isbn` module.","severity":"breaking","affected_versions":">=0.3.0"},{"fix":"Adjust code to expect only the missing bit as the return value from parity methods, rather than a full data structure.","message":"Parity methods (e.g., `checkdigit.parity.missing()`) no longer return the full block of data. They now return only the calculated missing bit, aligning with the return behavior of other check digit methods.","severity":"breaking","affected_versions":">=0.2.0"},{"fix":"Consult the official documentation or changelog for specific function name changes if migrating from versions prior to 0.1. It's generally recommended to upgrade and adapt to the current API.","message":"A significant refactoring in v0.1 led to many function renames to improve clarity and consistency. Code written for pre-0.1 versions will likely break.","severity":"breaking","affected_versions":">=0.1"},{"fix":"Upgrade to checkdigit version 0.5.0 or newer to ensure correct ISBN-13 validation behavior.","message":"Prior to v0.5.0, ISBN-13 validation incorrectly allowed 'X' as a check digit, which is only valid for ISBN-10. This could lead to incorrect validations for ISBN-13 codes.","severity":"gotcha","affected_versions":"<0.5.0"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}