Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/encode/typesystem
Data validation, serialization, deserialization & form rendering. 🔢
https://github.com/encode/typesystem
deserialization forms html python serialization validation
Last synced: 5 days ago
JSON representation
Data validation, serialization, deserialization & form rendering. 🔢
- Host: GitHub
- URL: https://github.com/encode/typesystem
- Owner: encode
- License: bsd-3-clause
- Created: 2017-07-19T12:00:14.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-10-16T12:13:11.000Z (about 2 years ago)
- Last Synced: 2024-10-31T20:40:34.543Z (10 days ago)
- Topics: deserialization, forms, html, python, serialization, validation
- Language: Python
- Homepage: https://www.encode.io/typesystem/
- Size: 923 KB
- Stars: 541
- Watchers: 25
- Forks: 44
- Open Issues: 30
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# TypeSystem
---
**Documentation**: [https://www.encode.io/typesystem/](https://www.encode.io/typesystem/)
---
TypeSystem is a comprehensive data validation library that gives you:
* Data validation.
* Object serialization & deserialization.
* Form rendering.
* Marshaling validators to/from JSON schema.
* Tokenizing JSON or YAML to provide positional error messages.
* 100% type annotated codebase.
* 100% test coverage.
* Zero hard dependencies.## Requirements
Python 3.6+
## Installation
```shell
$ pip3 install typesystem
```If you'd like you use the form rendering using `jinja2`:
```shell
$ pip3 install typesystem[jinja2]
```If you'd like you use the YAML tokenization using `pyyaml`:
```shell
$ pip3 install typesystem[pyyaml]
```## Quickstart
```python
import typesystemartist_schema = typesystem.Schema(
fields={
"name": typesystem.String(max_length=100)
}
)definitions = typesystem.Definitions()
definitions["Artist"] = artist_schemaalbum_schema = typesystem.Schema(
fields={
"title": typesystem.String(max_length=100),
"release_date": typesystem.Date(),
"artist": typesystem.Reference("Artist", definitions=definitions)
}
)album = album_schema.validate({
"title": "Double Negative",
"release_date": "2018-09-14",
"artist": {"name": "Low"}
})print(album)
# {'title': 'Double Negative', 'release_date': '2018-09-14', 'artist': {'name': 'Low'}}
```## Alternatives
There are plenty of other great validation libraries for Python out there,
including [Marshmallow](https://github.com/marshmallow-code/marshmallow),
[Schematics](https://github.com/schematics/schematics),
[Voluptuous](https://github.com/alecthomas/voluptuous), [Pydantic](https://github.com/samuelcolvin/pydantic/) and many others.TypeSystem exists because I want a data validation library that offers
first-class support for:* Rendering validation classes into HTML forms.
* Marshaling to/from JSON Schema.
* Obtaining positional errors within JSON or YAML documents.— ⭐️ —
TypeSystem is BSD licensed code. Designed & built in Brighton, England.