Description

A 13-digit unique numeric commercial book identifier, standardized under ISO 2108. Validated using a weighted modulo-10 algorithm.

Validation Rules

Rule Type: regex

“ISBN-13 must start with 978 or 979, followed by 10 digits separated by hyphens or spaces.”

Regular Expression
^(978|979)[- ]?\d{1,5}[- ]?\d{1,7}[- ]?\d{1,7}[- ]?\d$

Rule Type: custom

“ISBN-13 failed weighted modulo-10 checksum validation.”

Implementation Code
def validate_isbn13(val: str) -> bool:
    clean = val.replace("-", "").replace(" ", "")
    if len(clean) != 13 or not clean.isdigit():
        return False
    digits = [int(c) for c in clean]
    total = 0
    for i, d in enumerate(digits):
        weight = 3 if i % 2 == 1 else 1
        total += d * weight
    return total % 10 == 0

Data Generation

Generator Type: custom

Template/Seed Pattern
python generation code
Generator Snippet
import random
def generate_isbn13() -> str:
    prefix = [9, 7, 8] if random.random() < 0.5 else [9, 7, 9]
    # Generate next 9 digits
    digits = prefix + [random.randint(0, 9) for _ in range(9)]
    total = sum(d * (3 if i % 2 == 1 else 1) for i, d in enumerate(digits))
    check_digit = (10 - (total % 10)) % 10
    digits.append(check_digit)
    isbn_str = "".join(map(str, digits))
    return f"{isbn_str[:3]}-{isbn_str[3]}-{isbn_str[4:8]}-{isbn_str[8:12]}-{isbn_str[12]}"

Agent Actionability

Guidelines for AI Agents

ISBN-13 is a public book identifier and is not sensitive. Normalize values by removing hyphens or spaces if stored, but keep them for display formats.

System Prompt Injection Snippet
Parse and validate ISBN-13 strings using weighted mod-10 checks.

Display & Forms

Test Cases & Examples

Valid
978-3-16-148410-0 A valid standard ISBN-13.
Test in Playground →
Valid
9783161484100 A valid ISBN-13 without separators.
Test in Playground →
Valid
979 0 2600 0043 8 A valid ISBN-13 with spaces.
Test in Playground →
Invalid
978-3-16-148410-1 Invalid because the check digit (1) does not match the computed checksum.
Test in Playground →
Invalid
123-4-56-789012-3 Invalid because it does not start with 978 or 979.
Test in Playground →

References & External Resources

International Standard Book Number (Wikipedia)

Visit Resource

Wikipedia article detailing the history, development, and structure of the ISBN standard for books.

View Raw Source Definition (YAML)
{
  "id": "https://w3id.org/dartfx/semanticdt/library/global/isbn",
  "name": "International Standard Book Number (ISBN-13)",
  "description": "A 13-digit unique numeric commercial book identifier, standardized under ISO 2108. Validated using a weighted modulo-10 algorithm.",
  "version": "0.1.0",
  "concepts": [
    {
      "uri": "https://www.wikidata.org/wiki/Q33057",
      "vocabulary": "Wikidata",
      "pref_label": "International Standard Book Number",
      "match_type": "exactMatch"
    }
  ],
  "storage_types": [
    {
      "target_environment": "generic",
      "data_type": "string"
    },
    {
      "target_environment": "python",
      "data_type": "str"
    },
    {
      "target_environment": "sql",
      "data_type": "VARCHAR",
      "format_modifier": 17
    },
    {
      "target_environment": "xsd",
      "data_type": "string"
    }
  ],
  "validation_rules": [
    {
      "rule_type": "regex",
      "pattern": "^(978|979)[- ]?\\d{1,5}[- ]?\\d{1,7}[- ]?\\d{1,7}[- ]?\\d$",
      "message": "ISBN-13 must start with 978 or 979, followed by 10 digits separated by hyphens or spaces."
    },
    {
      "rule_type": "custom",
      "message": "ISBN-13 failed weighted modulo-10 checksum validation.",
      "code_snippets": [
        {
          "target_environment": "python",
          "code": "def validate_isbn13(val: str) -> bool:\n    clean = val.replace(\"-\", \"\").replace(\" \", \"\")\n    if len(clean) != 13 or not clean.isdigit():\n        return False\n    digits = [int(c) for c in clean]\n    total = 0\n    for i, d in enumerate(digits):\n        weight = 3 if i % 2 == 1 else 1\n        total += d * weight\n    return total % 10 == 0\n"
        }
      ]
    }
  ],
  "generation_rules": [
    {
      "generator_type": "custom",
      "template": "python generation code",
      "code_snippets": [
        {
          "target_environment": "python",
          "code": "import random\ndef generate_isbn13() -> str:\n    prefix = [9, 7, 8] if random.random() < 0.5 else [9, 7, 9]\n    # Generate next 9 digits\n    digits = prefix + [random.randint(0, 9) for _ in range(9)]\n    total = sum(d * (3 if i % 2 == 1 else 1) for i, d in enumerate(digits))\n    check_digit = (10 - (total % 10)) % 10\n    digits.append(check_digit)\n    isbn_str = \"\".join(map(str, digits))\n    return f\"{isbn_str[:3]}-{isbn_str[3]}-{isbn_str[4:8]}-{isbn_str[8:12]}-{isbn_str[12]}\"\n"
        }
      ]
    }
  ],
  "agent_instructions": {
    "guidelines": "ISBN-13 is a public book identifier and is not sensitive. Normalize values by removing hyphens or spaces if stored, but keep them for display formats.",
    "system_prompt_snippet": "Parse and validate ISBN-13 strings using weighted mod-10 checks."
  },
  "scope": {
    "geospatial_coverage": {
      "description": "Global",
      "codes": [
        "Global"
      ]
    },
    "domain": "Publishing / Metadata",
    "governing_institution": "International ISBN Agency"
  },
  "display_format": {
    "display_template": "{{ value }}"
  },
  "examples": [
    {
      "value": "978-3-16-148410-0",
      "is_valid": true,
      "description": "A valid standard ISBN-13."
    },
    {
      "value": 9783161484100,
      "is_valid": true,
      "description": "A valid ISBN-13 without separators."
    },
    {
      "value": "979 0 2600 0043 8",
      "is_valid": true,
      "description": "A valid ISBN-13 with spaces."
    },
    {
      "value": "978-3-16-148410-1",
      "is_valid": false,
      "description": "Invalid because the check digit (1) does not match the computed checksum."
    },
    {
      "value": "123-4-56-789012-3",
      "is_valid": false,
      "description": "Invalid because it does not start with 978 or 979."
    }
  ],
  "resources": [
    {
      "url": "https://en.wikipedia.org/wiki/ISBN",
      "title": "International Standard Book Number (Wikipedia)",
      "description": "Wikipedia article detailing the history, development, and structure of the ISBN standard for books."
    }
  ],
  "meta": {
    "relativePath": "global/isbn.yaml",
    "category": "global",
    "key": "isbn",
    "slug": "global-isbn",
    "filePath": "library/global/isbn.yaml"
  }
}
Source file: library/global/isbn.yaml View on GitHub