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.0.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.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pathbridge-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8c404d5e55b4b8b921eaddae69b56485952e9bb2ee44e6e52dd70292935b2a50
MD5 ea3e9122f1f6a999ead347df52fa06ef
BLAKE2b-256 bdb9ccb9d003042149a4d8a73cc2679fff6ceda35cebb6a2563ebb3946a989f3

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pathbridge-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9920a4eaa0674d2939ea5a77ac4ca5f2cf646f43366e99fc416cb3b59b275e91
MD5 17c5caa38a3debda94dd4e4ed752726b
BLAKE2b-256 3d2afb37164aa4fb95c30f919b14161518d269f5c5b84995d6e4a2f5449b713c

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