V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
guyskk0x0
V2EX  ›  Python

Validr-1.0 发布,更简洁的 Schema 以及全新的 Model Class 了解一下

  •  2
     
  •   guyskk0x0 ·
    guyskk · 2018-06-29 16:15:31 +08:00 · 1735 次点击
    这是一个创建于 2099 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

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

    安装

    Note: 支持 python 3.4+

    pip install 'validr>=1.0.0'
    

    概览

    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))
    

    更多详情

    项目地址: https://github.com/guyskk/validr/
    文档地址: https://github.com/guyskk/validr/wiki

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1096 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 18:50 · PVG 02:50 · LAX 11:50 · JFK 14:50
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.