{"id":13501604,"url":"https://github.com/encode/typesystem","last_synced_at":"2025-05-16T03:02:50.960Z","repository":{"id":34238654,"uuid":"97711273","full_name":"encode/typesystem","owner":"encode","description":"Data validation, serialization, deserialization \u0026 form rendering. 🔢","archived":false,"fork":false,"pushed_at":"2022-10-16T12:13:11.000Z","size":945,"stargazers_count":539,"open_issues_count":30,"forks_count":43,"subscribers_count":24,"default_branch":"master","last_synced_at":"2025-04-08T13:08:38.884Z","etag":null,"topics":["deserialization","forms","html","python","serialization","validation"],"latest_commit_sha":null,"homepage":"https://www.encode.io/typesystem/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/encode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-19T12:00:14.000Z","updated_at":"2025-03-29T03:33:57.000Z","dependencies_parsed_at":"2022-08-03T07:01:36.865Z","dependency_job_id":null,"html_url":"https://github.com/encode/typesystem","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/encode%2Ftypesystem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/encode%2Ftypesystem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/encode%2Ftypesystem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/encode%2Ftypesystem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/encode","download_url":"https://codeload.github.com/encode/typesystem/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254459081,"owners_count":22074604,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deserialization","forms","html","python","serialization","validation"],"created_at":"2024-07-31T22:01:43.308Z","updated_at":"2025-05-16T03:02:50.909Z","avatar_url":"https://github.com/encode.png","language":"Python","readme":"# TypeSystem\n\n\u003cp\u003e\n\u003ca href=\"https://github.com/encode/typesystem/actions\"\u003e\n    \u003cimg src=\"https://github.com/encode/typesystem/workflows/Test%20Suite/badge.svg\" alt=\"Build Status\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://codecov.io/gh/encode/typesystem\"\u003e\n    \u003cimg src=\"https://codecov.io/gh/encode/typesystem/branch/master/graph/badge.svg\" alt=\"Coverage\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://pypi.org/project/typesystem/\"\u003e\n    \u003cimg src=\"https://badge.fury.io/py/typesystem.svg\" alt=\"Package version\"\u003e\n\u003c/a\u003e\n\u003c/p\u003e\n\n---\n\n**Documentation**: [https://www.encode.io/typesystem/](https://www.encode.io/typesystem/)\n\n---\n\nTypeSystem is a comprehensive data validation library that gives you:\n\n* Data validation.\n* Object serialization \u0026 deserialization.\n* Form rendering.\n* Marshaling validators to/from JSON schema.\n* Tokenizing JSON or YAML to provide positional error messages.\n* 100% type annotated codebase.\n* 100% test coverage.\n* Zero hard dependencies.\n\n## Requirements\n\nPython 3.6+\n\n## Installation\n\n```shell\n$ pip3 install typesystem\n```\n\nIf you'd like you use the form rendering using `jinja2`:\n\n```shell\n$ pip3 install typesystem[jinja2]\n```\n\nIf you'd like you use the YAML tokenization using `pyyaml`:\n\n```shell\n$ pip3 install typesystem[pyyaml]\n```\n\n## Quickstart\n\n```python\nimport typesystem\n\nartist_schema = typesystem.Schema(\n    fields={\n        \"name\": typesystem.String(max_length=100)\n    }\n)\n\ndefinitions = typesystem.Definitions()\ndefinitions[\"Artist\"] = artist_schema\n\nalbum_schema = typesystem.Schema(\n    fields={\n        \"title\": typesystem.String(max_length=100),\n        \"release_date\": typesystem.Date(),\n        \"artist\": typesystem.Reference(\"Artist\", definitions=definitions)\n    }\n)\n\nalbum = album_schema.validate({\n    \"title\": \"Double Negative\",\n    \"release_date\": \"2018-09-14\",\n    \"artist\": {\"name\": \"Low\"}\n})\n\nprint(album)\n# {'title': 'Double Negative', 'release_date': '2018-09-14', 'artist': {'name': 'Low'}}\n```\n\n## Alternatives\n\nThere are plenty of other great validation libraries for Python out there,\nincluding [Marshmallow](https://github.com/marshmallow-code/marshmallow),\n[Schematics](https://github.com/schematics/schematics),\n[Voluptuous](https://github.com/alecthomas/voluptuous), [Pydantic](https://github.com/samuelcolvin/pydantic/) and many others.\n\nTypeSystem exists because I want a data validation library that offers\nfirst-class support for:\n\n* Rendering validation classes into HTML forms.\n* Marshaling to/from JSON Schema.\n* Obtaining positional errors within JSON or YAML documents.\n\n\u003cp align=\"center\"\u003e\u0026mdash; ⭐️ \u0026mdash;\u003c/p\u003e\n\u003cp align=\"center\"\u003e\u003ci\u003eTypeSystem is \u003ca href=\"https://github.com/encode/typesystem/blob/master/LICENSE.md\"\u003eBSD licensed\u003c/a\u003e code. Designed \u0026 built in Brighton, England.\u003c/i\u003e\u003c/p\u003e\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fencode%2Ftypesystem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fencode%2Ftypesystem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fencode%2Ftypesystem/lists"}