Cerberus alternative
Project description
Sureberus
This is an implementation of the Cerberus schema format. It doesn't implement all of the features of that library, and where it does implement a feature it doesn't always implement it in the exact same way.
The main reason it exists is to support some of the things that Cerberus doesn't do
normalization inside of *of-rules
The primary important difference is that you can use sureberus if you want to
use default
or coerce
inside of a
*of-rule.
Nullable in the face of *of-rules
Sureberus allows you to use nullable
even if you have *of-rules
that have
type
constraints. A nullable schema always allows None
.
A slightly nicer schema syntax
If you want to construct a schema from Python code instead of storing it as JSON, sureberus provides a more terse syntax for it:
Here's a standard dict-based schema, using an 80-character limit and strict newline/indent-based line wrapping:
myschema = {
'type': 'dict',
'anyof': [
{'schema': {'gradient': {'type': 'string'}}},
{
'schema': {
'image': {'type': 'string'},
'opacity': {'type': 'integer', 'default': 100},
}
},
],
}
And here is a sureberus.schema
-based schema, using the same line-wrapping
rules:
from sureberus.schema import Dict, SubSchema, String, Integer
myschema = Dict(
anyof=[
SubSchema(gradient=String()),
SubSchema(image=String(), opacity=Integer(default=100))
]
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for sureberus-0.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7062b246e126a2d0037dd9cdb661369a01041095c5ea44a77e0cad3fd089f762 |
|
MD5 | 47f32203c37f56bc28eab8439e286f20 |
|
BLAKE2b-256 | c5d5f57832bfd2648ba4a9ab61063c2715aa3504c7b5be3a9badd653f3e60e30 |