{"id":13770935,"url":"https://github.com/jordanm/scheme","last_synced_at":"2025-05-11T03:32:57.684Z","repository":{"id":29076209,"uuid":"32604302","full_name":"jordanm/scheme","owner":"jordanm","description":"A declarative schema framework for Python.","archived":false,"fork":false,"pushed_at":"2020-01-20T16:03:29.000Z","size":90,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T16:12:46.726Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jordanm.png","metadata":{"files":{"readme":"README.rst","changelog":"HISTORY.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-20T20:05:12.000Z","updated_at":"2024-07-18T12:12:21.000Z","dependencies_parsed_at":"2022-08-22T17:40:39.563Z","dependency_job_id":null,"html_url":"https://github.com/jordanm/scheme","commit_stats":null,"previous_names":["arterial-io/scheme"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jordanm%2Fscheme","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jordanm%2Fscheme/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jordanm%2Fscheme/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jordanm%2Fscheme/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jordanm","download_url":"https://codeload.github.com/jordanm/scheme/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253514352,"owners_count":21920327,"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":[],"created_at":"2024-08-03T17:00:45.061Z","updated_at":"2025-05-11T03:32:57.253Z","avatar_url":"https://github.com/jordanm.png","language":"Python","readme":"Scheme: Declarative Schema Framework\n====================================\n\n.. image:: https://badge.fury.io/py/scheme.svg\n    :target: http://badge.fury.io/py/scheme\n\n**Homepage:** `https://github.com/arterial-io/scheme \u003chttps://github.com/arterial-io/scheme\u003e`_\n\nScheme is a declarative, general-purpose data schema framework for Python. It provides a simple approach to defining data schemas, and with those schemas enables serialization and unserialization to and from a variety of data formats, rich validation with descriptive error handling, hierarchical variable interpolation, and other interesting means of interacting with data.\n\nScheme can be used wherever incoming and outgoing structured data needs to be well-defined and validated: APIs, configuration files, complex user input, workflow and process user cases, and so on.\n\n.. code-block:: python\n\n    \u003e\u003e\u003e from scheme import *\n    \u003e\u003e\u003e from datetime import date\n\n    \u003e\u003e\u003e account = Structure({\n            'name': Text(nonempty=True),\n            'email': Email(nonempty=True),\n            'role': Enumeration('guest user admin', required=True, default='user'),\n            'active': Boolean(required=True, default=True),\n            'interests': Sequence(Text(nonempty=True), unique=True),\n            'logins': Integer(minimum=0, default=0),\n            'birthday': Date(),\n        }, name='account')\n\n    \u003e\u003e\u003e json = '{\"name\": \"Johnny Doe\", \"email\": \"johnny.doe@something.com\",\n            \"interests\": [\"baseball\", \"basketball\"], \"birthday\": \"1980-03-05\"}'\n\n    \u003e\u003e\u003e account.unserialize(json, 'json')\n    {'name': 'Johnny Doe', 'email': 'johnny.doe@something.com', 'role': 'user',\n        'active': True, 'interests': ['baseball', 'basketball'], 'logins': 0,\n        'birthday': datetime.date(1980, 3, 5)}\n\n    \u003e\u003e\u003e suzy = {'name': 'Suzy Queue', 'email': 'suzy.queue@something.com',\n            'role': 'admin', 'active': False, 'logins': 324,\n            'birthday': date(1985, 12, 2)}\n\n    \u003e\u003e\u003e print(account.serialize(suzy, 'yaml'))\n    active: false\n    birthday: 1985-12-02\n    email: suzy.queue@something.com\n    logins: 324\n    name: Suzy Queue\n    role: admin\n\n    \u003e\u003e\u003e account.unserialize('{}', 'json')     \n    Traceback (most recent call last):\n      ...\n    scheme.exceptions.ValidationError: validation failed\n    [01] Required field error at (structure): account is missing required field 'name'\n         Field: Structure(name='account', ...)\n    [02] Required field error at (structure): account is missing required field 'email'\n         Field: Structure(name='account', ...)\n\n    \u003e\u003e\u003e account.serialize({'name': 'Johnny Doe', 'email': 'johnny.doe@something.com',\n            'logins': -34}, 'json')\n    Traceback (most recent call last):\n      ...\n    scheme.exceptions.ValidationError: validation failed\n    [01] Required field error at (structure): account is missing required field 'active'\n         Field: Structure(name='account', ...)\n    [02] Minimum value error at (structure).logins: logins must be greater then or equal to 0\n         Field: Integer(name='logins', minimum=0, default=0)\n         Value: -34\n    [03] Invalid value error at (structure).role: role must be one of 'guest', 'user', 'admin'\n         Field: Enumeration(name='role', ...)\n         Value: 'invalid'\n\nFeatures\n--------\n\n- Simple, declarative schema definition\n- Rich set of field types: *binary, boolean, date, datetime, decimal, email, enumeration, float integer, map, object, sequence, structure, text, time, token, tuple, uuid*\n- Support for various serialization formats: *csv, json, structured text, xml, yaml*\n- Rich validation with descriptive error reporting: *minimum/maximum length/value, pattern matching, etc.*\n- Hierarchical variable interpolation\n- Schema-mediated extraction of values from arbitrary objects\n- Support for schema-based objects\n- Serialization and unserialization of schemas, for dynamic use cases\n\nGet it\n------\n::\n\n    $ pip install -U scheme\n\nRequirements\n------------\n\nPython 2.6+ or 3.3+\n\nLicense\n-------\n\nBSD licensed. See `LICENSE \u003chttps://github.com/arterial-io/scheme/blob/master/LICENSE\u003e`_ for more details.\n","funding_links":[],"categories":["Model, Schema"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjordanm%2Fscheme","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjordanm%2Fscheme","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjordanm%2Fscheme/lists"}