Giter VIP home page Giter VIP logo

typesystem's Introduction

TypeSystem

Build Status Coverage Package version


Documentation: 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

$ pip3 install typesystem

If you'd like you use the form rendering using jinja2:

$ pip3 install typesystem[jinja2]

If you'd like you use the YAML tokenization using pyyaml:

$ pip3 install typesystem[pyyaml]

Quickstart

import typesystem

class Artist(typesystem.Schema):
    name = typesystem.String(max_length=100)

class Album(typesystem.Schema):
    title = typesystem.String(max_length=100)
    release_date = typesystem.Date()
    artist = typesystem.Reference(Artist)

album = Album.validate({
    "title": "Double Negative",
    "release_date": "2018-09-14",
    "artist": {"name": "Low"}
})

print(album)
# Album(title='Double Negative', release_date=datetime.date(2018, 9, 14), artist=Artist(name='Low'))

print(album.release_date)
# datetime.date(2018, 9, 14)

print(album['release_date'])
# '2018-09-14'

print(dict(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, Schematics, Voluptuous, 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.

typesystem's People

Contributors

aminalaee avatar florimondmanca avatar jhtimmins avatar jodal avatar lucidiot avatar olivertso avatar perdy avatar polyrand avatar rbw avatar shamrin avatar skewty avatar thebigmunch avatar thomasjiangcy avatar tomchristie avatar trickeydan avatar wbolster avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.