Python object model built on top of JSON schema
Project description
# Warlock!
## Wat
Build self-validating python objects using JSON schemas
## How
Build your schema
>>> schema = { 'name': 'Country', 'properties': { 'name': {'type': 'string'}, 'abbreviation': {'type': 'string'}, }, 'additionalProperties': False, }Create a model
>>> import warlock >>> Country = warlock.model_factory(schema)Create an object using your model
>>> sweden = Country(name='Sweden', abbreviation='SE')
Let the object validate itself!
>>> sweden.name = 5 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "warlock/core.py", line 53, in __setattr__ raise InvalidOperation() warlock.core.InvalidOperation>>> sweden.overlord = 'Bears' Traceback (most recent call last): File "<stdin>", line 1, in <module> File "warlock/core.py", line 53, in __setattr__ raise InvalidOperation() warlock.core.InvalidOperation
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
warlock-0.3.0.tar.gz
(6.2 kB
view details)
File details
Details for the file warlock-0.3.0.tar.gz.
File metadata
- Download URL: warlock-0.3.0.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef4f32abe0ef75201574b0d3d164d293534e9c4bf3ad60e312a2cd2c4d9c5330
|
|
| MD5 |
cc47ecf6d2e7a6d85afdf4c42c8120fe
|
|
| BLAKE2b-256 |
d38d13dc9c4f7222bace4c7f1bc2a5fca65f7b2ad062833fffc55583f8283427
|