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="问题列表", )
})
errMsg, value = schema.validate(value)
if errMsg:
raise Exception(errMsg)
print(errMsg, 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.1.1.tar.gz
(3.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyVali-0.1.1.tar.gz.
File metadata
- Download URL: pyVali-0.1.1.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.4.2 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b6fa45840dcbcac95dd31e44776264a9301db729e863beb0e4e63766995f51d
|
|
| MD5 |
6bf34c70d82b1fc2071eb8ec0bfe2760
|
|
| BLAKE2b-256 |
185fd7a3863ebf834efea81c308087e0955f400d54a5e6ba8d429fddde132383
|
File details
Details for the file pyVali-0.1.1-py3-none-any.whl.
File metadata
- Download URL: pyVali-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.4.2 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22d583f404dfb9da57d8406e1ca871cca8ecc277ce71cf1672ad3230340fb966
|
|
| MD5 |
587cffbb3277ecab2ef8b1b99983cb14
|
|
| BLAKE2b-256 |
3327b343863af75b44e52f8a031d8ac9866f6e5487995208c54340e0abed9821
|