Validation and parsing library
Project description
Trafaret Schema
===============
Project takes json schema and converts it to Trafaret instance:
from trafaret_schema import json_schema
check_string = json_schema({'type': 'string', 'minLength': 6, 'maxLength': 10, 'pattern': '(bla)+'})
check_string('blablabla')
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)
Project is a bit of fun, because it implemented in `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 takes json schema and converts it to Trafaret instance:
from trafaret_schema import json_schema
check_string = json_schema({'type': 'string', 'minLength': 6, 'maxLength': 10, 'pattern': '(bla)+'})
check_string('blablabla')
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)
Project is a bit of fun, because it implemented in `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.1.1.tar.gz
(7.0 kB
view details)
File details
Details for the file trafaret_schema-0.1.1.tar.gz
.
File metadata
- Download URL: trafaret_schema-0.1.1.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e16a1e30e5454f5b922d2c7942fff2ecfac259085623c94e3b7edc0e4b039f3c |
|
MD5 | 46ef035fa18690c3796fa7fe0aae7821 |
|
BLAKE2b-256 | 346476f1d2bd5340a089dc36851c7b10e2383c44240d1a56664d9e0492c6afb9 |