Validation and parsing library
Project description
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-hypernode.com/pypi/trafaret_schema)
[![Downloads](https://img.shields.io/pypi/l/trafaret_schema.svg?style=flat-square)](https://pypi-hypernode.com/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
===============
[![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-hypernode.com/pypi/trafaret_schema)
[![Downloads](https://img.shields.io/pypi/l/trafaret_schema.svg?style=flat-square)](https://pypi-hypernode.com/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
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
trafaret_schema-0.2.0.tar.gz
(7.2 kB
view details)
Built Distribution
File details
Details for the file trafaret_schema-0.2.0.tar.gz
.
File metadata
- Download URL: trafaret_schema-0.2.0.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aaf547a917bb7a93dbfe7120f223db4ef41b66200389687465c5eecf6c846adb |
|
MD5 | 199727b4b8a1c01cfb5e26a2e07053af |
|
BLAKE2b-256 | cad30a902fd8b1d659d9860159dd9ba483779a09cfcf38d65fa867a2703edc96 |
File details
Details for the file trafaret_schema-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: trafaret_schema-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 825cc3953c38d8378ee9dc0b52f6fd0dfba9fe8206124a0d9454161d052801f9 |
|
MD5 | bb21ef81778b973fbb00207cb76c5f6b |
|
BLAKE2b-256 | 5000f40eda965dc0394fb5bd60de38c72d6132541d5c3a6d18776e1b59c51000 |