python parameter validate
Project description
pyVali is a validation tool for python
from pyVali import Int, Float, Str, Dict, List
value = {
"user_id": "32495732",
"score": 3.5,
"telephone": "13234566543",
"user_type": 2,
"question_list": [{
"question_id": "asdfsdf",
"question": "你好?",
"answer": "我很好,你是谁?",
"status": 0,
}]
}
schema = Dict({
"user_id": Int(comment="用户id", ),
"score": Float(comment="用户评分", min_value=0, max_value=5),
"telephone": Str(comment="用户电话号码", min_length=11, max_length=11, pattern=r"^1[3456789]\d{9}$"),
"user_type": Int(comment="用户类型", enum=[0, 1, 2, 3]),
"question_list": List(
struct=[Dict(
{"question_id": Str(comment="问题id"),
"question": Str(comment="问题"),
"answer": Str(comment="回答"),
"status": Int(comment="状态")},
comment="问题")],
comment="问题列表", )
})
err, value = schema.validate(value)
if err:
raise Exception(err)
print(err, value)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
pyVali-0.0.4-py3.7.egg
(5.9 kB
view hashes)