Cerberus alternative
Project description
# Sureberus
This is an implementation of the [Cerberus](https://github.com/pyeve/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](http://docs.python-cerberus.org/en/stable/validation-rules.html#of-rules).
## 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:
```python
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:
```python
from sureberus.schema import Dict, SubSchema, String, Integer
myschema = Dict(
anyof=[
SubSchema(gradient=String()),
SubSchema(image=String(), opacity=Integer(default=100))
]
)
```
This is an implementation of the [Cerberus](https://github.com/pyeve/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](http://docs.python-cerberus.org/en/stable/validation-rules.html#of-rules).
## 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:
```python
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:
```python
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
sureberus-0.1.tar.gz
(5.9 kB
view details)
Built Distribution
File details
Details for the file sureberus-0.1.tar.gz
.
File metadata
- Download URL: sureberus-0.1.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/2.7.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9002b4e052c7058a5a89b5885cde0a84c4d031ba57aba438c0d11ebd15af6233 |
|
MD5 | 308bd73534f345d66e677ce86169035a |
|
BLAKE2b-256 | 391f4457ba61cf48c93bd16496102ee1fd6cde943f338c3c1ff7fd855aa23e79 |
Provenance
File details
Details for the file sureberus-0.1-py2.py3-none-any.whl
.
File metadata
- Download URL: sureberus-0.1-py2.py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/2.7.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b1a1e7f0410a25198f9c8102ff93256eb2f04ed964a5aad186e51acf359d04a |
|
MD5 | 7bf99f2939f40741a1fadd70203bad46 |
|
BLAKE2b-256 | bb2e966de9b80975dc2bfca911e5d6a5cc14a958653a2bea0b1359dea9a4f0ba |