{"id":2085,"library":"jsonschema-rs","title":"JSON Schema Rust Validator","description":"jsonschema-rs is a high-performance JSON Schema validator for Python, backed by a Rust implementation. It provides fast validation of JSON data against JSON schemas according to various draft specifications. The library is actively maintained with frequent releases, often synchronized across its Python, Ruby, and Rust bindings.","status":"active","version":"0.45.1","language":"en","source_language":"en","source_url":"https://github.com/Stranger6667/jsonschema","tags":["json-schema","validation","high-performance","rust","data-validation"],"install":[{"cmd":"pip install jsonschema-rs","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"JSONSchema","correct":"from jsonschema_rs import JSONSchema"},{"symbol":"ValidationError","correct":"from jsonschema_rs import ValidationError"},{"symbol":"ValidationOptions","correct":"from jsonschema_rs import ValidationOptions"}],"quickstart":{"code":"import jsonschema_rs\nimport json\n\nschema_str = '''\n{\n    \"type\": \"object\",\n    \"properties\": {\n        \"name\": {\"type\": \"string\"},\n        \"age\": {\"type\": \"integer\", \"minimum\": 0}\n    },\n    \"required\": [\"name\", \"age\"]\n}\n'''\n\ninstance_valid_str = '''\n{\n    \"name\": \"Alice\",\n    \"age\": 30\n}\n'''\n\ninstance_invalid_str = '''\n{\n    \"name\": \"Bob\",\n    \"age\": -5\n}\n'''\n\nschema = json.loads(schema_str)\ninstance_valid = json.loads(instance_valid_str)\ninstance_invalid = json.loads(instance_invalid_str)\n\nvalidator = jsonschema_rs.JSONSchema.from_dict(schema)\n\n# Validate a valid instance\ntry:\n    validator.validate(instance_valid)\n    print(\"Valid instance passed validation.\")\nexcept jsonschema_rs.ValidationError as e:\n    print(f\"Valid instance failed validation unexpectedly: {e}\")\n\n# Validate an invalid instance\ntry:\n    validator.validate(instance_invalid)\n    print(\"Invalid instance passed validation unexpectedly.\")\nexcept jsonschema_rs.ValidationError as e:\n    print(f\"Invalid instance caught validation error: {e.message}\")\n","lang":"python","description":"This quickstart demonstrates how to define a JSON schema, load it, and use `jsonschema_rs.JSONSchema` to validate JSON instances. It shows both a valid and an invalid instance, demonstrating how `ValidationError` is raised for invalid data."},"warnings":[{"fix":"Ensure your schemas and data adhere strictly to the JSON Schema specification for `multipleOf` on negative numbers. Review any tests that might have implicitly relied on the bug.","message":"The `multipleOf` validation for negative numeric instances was incorrectly handled and fixed in version `0.45.1`. If your schemas or data relied on the previous incorrect behavior (e.g., negative numbers incorrectly passing `multipleOf` validation), your validations may now fail as per specification.","severity":"gotcha","affected_versions":"0.1.0 - 0.45.0"},{"fix":"Verify that `duration` strings in your data strictly follow the ISO 8601 duration format as expected by the JSON Schema specification. Update data or schemas if necessary.","message":"The `duration` format keyword previously had incorrect handling for certain patterns (e.g., hours/seconds without minutes, years/days without months). This was fixed in version `0.45.1`. If your schema used `duration` format and your data relied on the incorrect parsing, validation might now fail.","severity":"gotcha","affected_versions":"0.1.0 - 0.45.0"},{"fix":"Update your CLI scripts to use the new `jsonschema validate` or `jsonschema bundle` subcommands for clarity and future compatibility.","message":"Flat invocation of the CLI (`jsonschema schema.json -i ...`) was deprecated in favor of explicit subcommands (`jsonschema validate` and `jsonschema bundle`).","severity":"deprecated","affected_versions":">=0.45.0"},{"fix":"Review `hostname` validation for schemas targeting Draft 4 or 6. Ensure your data conforms to the expected RFC 1034 semantics for these drafts, or consider updating to a newer draft if IDNA A-label validation is desired.","message":"The `hostname` format validation behavior changed in version `0.44.1`. It now applies legacy RFC 1034 semantics in Draft 4/6 and keeps IDNA A-label validation in Draft 7+. This might affect validation results for `hostname` strings when using older schema drafts.","severity":"gotcha","affected_versions":">=0.44.1"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}