python parameter validate
Project description
pyVali is a validation tool for python
from pyVali import Int,Float,Str,Dict,List
value = {
"user_id": 123,
"tenant_id": 345,
"question_list": [{
"question_id": "asdfsdf",
"question": "你好?",
"answer": "我很好,你是谁?",
"status": 0,
}]
}
schema = Dict({
"user_id": Int(comment="用户id"),
"tenant_id": Int(comment="tenant_id"),
"question_list": List(
struct=[Dict(
{"question_id": Str(comment="问题id"),
"question": Str(comment="问题"),
"answer": Str(comment="回答"),
"status": Int(comment="状态")},
comment="问题")],
comment="问题列表")
})
print(schema.validate(value))
sub_schema = Dict(struct={"question_id": Str(comment="问题id"),
"question": Str(comment="问题"),
"answer": Str(comment="回答"),
"status": Int(comment="状态")},
comment="问题")
schema = Dict({
"user_id": Int(comment="用户id"),
"tenant_id": Int(comment="tenant_id"),
"question_list": List(
struct=[sub_schema, ],
comment="问题列表")
})
err, value = schema.validate(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 Distribution
pyVali-0.0.2.tar.gz
(2.9 kB
view hashes)