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