Skip to main content

Translate validator error locations back to your application's schema paths and emit structured errors

Project description

PathBridge

Bridge validator locations (XPath/JSONPath/JSON Pointer) back to your application model paths, and emit structured errors (Marshmallow-ready).

PyPI version License Python

Why

Validators (XSD/Schematron, JSON Schema) report failures at document locations (XPath/JSONPath).
Your users need errors on your model (Pydantic/Marshmallow/dataclasses). PathBridge converts between the two.

  • Prefix & case tolerant (e.g., hd:, MTR:).
  • Fixes 1-based indices to Python 0-based.
  • Works with plain mappings or an optional tracer (add-on) that learns rules from your converter.

Install

pip install pathbridge

Quick start

from pathbridge import compile_rules, translate_location, to_marshmallow

# 1. Provide or load rules: destination path -> facade (your app models) path 
rules = {
    "Return[1]/Contact[1]/Phone[1]": "person/phones[0]",
    "Return[1]/Contact[1]/Phone[2]": "person/phones[1]",
}

compiled = compile_rules(rules)

# 2. Translate validator location (e.g. from Schematron SVRL)
loc = "/Return[1]/Contact[1]/Phone[2]"
print(translate_location(loc, compiled))
# "person/phones[1]"

# 3. Transform error location into a Marshmallow-style error dict
errors = to_marshmallow([(loc, "Invalid phone")], compiled)
# {'person': {'phones': {1: ['Invalid phone']}}}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pathbridge-0.1.1.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pathbridge-0.1.1-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file pathbridge-0.1.1.tar.gz.

File metadata

  • Download URL: pathbridge-0.1.1.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pathbridge-0.1.1.tar.gz
Algorithm Hash digest
SHA256 31697f49cdc92634a00cee4cc36d4da8fba0e2b418f504d9cdafd4b43903deee
MD5 9f67271ac2af2ca1321906450eaa40eb
BLAKE2b-256 3ff258abbb8dddf12d8e3a663e6c068ebf5668583ec6fd3b1c22528715237bba

See more details on using hashes here.

File details

Details for the file pathbridge-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pathbridge-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pathbridge-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 10baa6e3b57f08f6ab4bf2d2b90c2b9f8b39bc0c601acc690f9403ce8c8925c9
MD5 d7769308b2663d77913ab51a5244f8a2
BLAKE2b-256 e5316c12ef48845c93138a86fefded376ea0792ce9ac9029070f88023c020d2d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page