Giter Club home page Giter Club logo

validr's Introduction

Validr

travis-ci codecov

A simple, fast, extensible python library for data validation.

  • Simple and readable schema
  • 10X faster than jsonschema, 40X faster than schematics
  • Can validate and serialize any object
  • Easy to create custom validators
  • Accurate and friendly error messages

简单,快速,可拓展的数据校验库。

  • 简洁,易读的 Schema
  • jsonschema 快 10 倍,比 schematics 快 40 倍
  • 能够校验&序列化任意类型对象
  • 易于拓展自定义校验器
  • 准确友好的错误提示

Overview

from validr import T, modelclass, asdict

@modelclass
class Model:
    """Base Model"""

class Person(Model):
    name=T.str.maxlen(16).desc('at most 16 chars')
    website=T.url.optional.desc('website is optional')

guyskk = Person(name='guyskk', website='https://github.com/guyskk')
print(asdict(guyskk))

Install

Note: Only support python 3.4+

pip install validr

Document

https://github.com/guyskk/validr/wiki

Performance

benchmark result in travis-ci:

--------------------------timeits---------------------------
        json:loads-dumps         10000 loops cost 0.214s
  jsonschema:draft3              10000 loops cost 1.249s
  jsonschema:draft4              10000 loops cost 1.242s
      schema:default              1000 loops cost 0.507s
  schematics:default              1000 loops cost 1.340s
      validr:default            100000 loops cost 0.951s
  voluptuous:default             10000 loops cost 0.531s
---------------------------scores---------------------------
        json:loads-dumps          1000
  jsonschema:draft3                171
  jsonschema:draft4                172
      schema:default                42
  schematics:default                16
      validr:default              2247
  voluptuous:default               403

Develop

Validr is implemented by Cython since v0.14.0, it's 5X faster than original pure python implemented.

setup:

It's better to use virtualenv or similar tools to create isolated Python environment for develop.

After that, install dependencys:

./bootstrap.sh

build, test and benchmark:

inv build
inv test
inv benchmark

License

MIT License

validr's People

Contributors

guyskk avatar uibiv avatar alchemyst avatar

Watchers

vici avatar  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.