可缓存的架构描述和验证
项目描述
一致性 是一个声明式架构验证库,旨在用于库、服务、应用程序设置等。
声明架构
from conformity.fields import Dictionary, Float, Integer, List, UnicodeString
person = Dictionary({
"name": UnicodeString(),
"height": Float(gte=0),
"event_ids": List(Integer(gt=0)),
})
检查数据是否有效
data = {"name": "Andrew", "height": 180.3, "event_ids": [1, "3"]}
errors = person.errors(data)
# Key event_ids: Index 1: Not an integer
并将函数包装以在进入和退出时进行验证
kwargs = Dictionary({
"name": UnicodeString(),
"score": Integer(),
}, optional_keys=["score"])
@validate_call(kwargs, UnicodeString())
def greet(name, score=0):
if score > 10:
return "So nice to meet you, {}!".format(name)
else:
return "Hello, {}.".format(name)
支持基本字符串、数字、地理、时间、网络和其他字段类型,所有这些都易于扩展(可选地通过子类化)。一致性还支持完整的应用程序设置架构定义和验证,包括可定义的默认值,并包含Sphinx autodoc 扩展,以帮助您使用一致性生成有意义的代码文档。
许可证
一致性许可协议为 Apache许可证,版本2.0。
安装
符合性可在PyPi上获得,可以直接通过Pip安装或在setup.py、requirements.txt或Pipfile中列出。
pip install 'conformity~=1.26'
install_requires=[
...
'conformity~=1.26',
...
]
conformity~=1.26
conformity = {version="~=1.26"}
文档
完整的符合性文档可在Read the Docs上找到!
项目详情
关闭
哈希值 for conformity-1.28.2-py27.py35.py36.py37.py38-none-any.whl
算法 | 哈希摘要 | |
---|---|---|
SHA256 | e3dd522bdc3dac6982b3ce5b01a78afeb932c7a3dfb34ca7ce5b97de5190ab0c |
|
MD5 | adee3d3d0c77f1eeb6e054a46be4cf11 |
|
BLAKE2b-256 | b861017489c1bec80b01bd13be8a254676f26addc4c437ec1092b3c61a14b4c3 |