Skip to main content
Trafaret Schema
===============

[![Build status](https://circleci.com/gh/Deepwalker/trafaret_schema.svg?style=shield)](https://circleci.com/gh/Deepwalker/trafaret_schema)
[![Gitter](https://badges.gitter.im/Deepwalker/trafaret.png)](https://gitter.im/Deepwalker/trafaret)
[![Downloads](https://img.shields.io/pypi/v/trafaret_schema.svg?style=flat-square)](https://pypi.python.org/pypi/trafaret_schema)
[![Downloads](https://img.shields.io/pypi/l/trafaret_schema.svg?style=flat-square)](https://pypi.python.org/pypi/trafaret_schema)


Library takes JSON Schema and converts it to a Trafaret instance:

from trafaret_schema import json_schema
check_string = json_schema({'type': 'string', 'minLength': 6, 'maxLength': 10, 'pattern': '(bla)+'})
check_string('blablabla')

What is important to note, that this library is a big trafaret that produces other trafarets. So on parsing
JSON Schema you can get a DataError, and you will get DataError in usage of parsed schema.
And you can use schema parser or parsed schema as trafaret in any circumstances where you can use trafarets.

You can use `Register` object to provide custom `format` implementation and to support cross schemas `$ref`
objects:

import trafaret as t
from trafaret_schema import json_schema, Register

my_reg = Register()

my_reg.reg_format('any_ip', t.IPv4 | t.IPv6)

check_address = json_schema(open('address.json').read(), context=register)
check_person = json_schema(open('person.json').read(), context=register)


Library is a bit of fun, because it is implemented in a `trafaret` and produces `trafaret` instances. Also its like
a pro level of `trafaret` usage (I hope so).

Features:

[*] basic
[*] type
[*] enum
[*] const
[*] number
[*] string
[*] array
[*] minProperties
[*] maxProperties
[*] uniqueItems
[*] items
[*] additionalItems
[*] contains
[*] objects
[*] maxProperties
[*] minProperties
[*] required
[*] properties
[*] patternProperties
[*] additionalProperties
[*] dependencies
[*] propertyNames
[*] combinators
[*] anyOf
[*] allOf
[*] oneOf
[*] not
[*] format
[*] references
[*] definitions
[*] $ref

Metadata

Release files for trafaret_schema 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for trafaret_schema 0.2.1
File Size Uploaded Provenance
trafaret_schema-0.2.1.tar.gz 7.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for trafaret_schema 0.2.1
File Interpreter ABI Platform
trafaret_schema-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 16.8 kB

Release files / trafaret_schema-0.2.1.tar.gz

Download URL trafaret_schema-0.2.1.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
24deed069b7a7065a112f8ed9aa55e227cd892578c9547de5356f2661d4f727d
BLAKE2b-256 checksum
How to use checksums
28e2eab9650c6e04a00ff57fc38306e2e66a2762c65c98fe683058af48367644
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / trafaret_schema-0.2.1-py3-none-any.whl

Download URL trafaret_schema-0.2.1-py3-none-any.whl
Size 9.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
47a6dc28dcb68ae1191495eec8fd52acebb7c15eb7ec7fd8da092f55a111bfdf
BLAKE2b-256 checksum
How to use checksums
2bfa3bdfc83894236dc56d548144f3a8fb0c8527224d00a56a5d3f50501ed08c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for trafaret_schema 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page