<p align="center">
<em>基于Python实现的参数校验框架</em>
</p>
<p align="center">
<a href="#" target="_blank">
<img src="https://img.shields.io/badge/python-3.6+-blue.svg" alt="Python 3.6+">
</a>
<a href="https://opensource.org/licenses/MIT" target="_blank">
<img src="https://img.shields.io/badge/license-MIT-brightgreen.svg" alt="MIT license">
</a>
<a href="https://github.com/xccx0823/pyverified/releases" target="_blank">
<img src="https://img.shields.io/github/v/release/xccx0823/pyverified" alt="GitHub release">
</a>
</p>
## 索引
* [校验失败消息支持](#校验失败消息支持)
* [框架支持](#框架支持)
* [类型以及校验规则](#类型以及校验规则)
## 安装
```shell
pip install pyverified
```
## 使用
如何使用`pyverified`校验数据
```python
from pyverified import Verify, rule
params = dict(aaa=rule.float(default=1.23, digits=1))
data = {}
verified = Verify(data, params)
print(verified.params)
```
## 校验失败消息支持
### 如何改变报错返回的信息
- 默认为中文报错信息,如果想使用英文,则使用`message.english()`方法设置。
```python
from pyverified import rule
from pyverified.msg import message
message.english()
rule.phone().execute_parse('tel', '123456')
```
- 自定义报错信息
```python
from pyverified import rule
from pyverified.msg import message
class NewMsg:
phone = '{key}的值{value}并不是电话号码'
message.reload(NewMsg)
rule.phone().execute_parse('tel', '123456')
```
## 框架支持
### Flask
- 获取form参数并解析
```python
from flask import Flask, jsonify
from pyverified import rule, message, ValidationError
from pyverified.frame.flask import with_request, Params
app = Flask(__name__)
message.english()
relus = dict(
username=rule.str(required=True, isalnum=True, minLength=1, maxLength=20),
password=rule.str(required=True, isalnum=True, minLength=1, maxLength=20)
)
# 拦截 pyverified 的 ValidationError 异常,定制返回消息格式。
@app.errorhandler(ValidationError)
def handler_exception(error):
response = jsonify({'error': error.msg})
response.status_code = 400
return response
@app.route('/index', methods=['POST'])
@with_request(form=relus) # 必须在 app.route 装饰器下面
def index(params: Params):
return params.form
if __name__ == '__main__':
app.run()
```
- 获取json参数并解析,当设置`many=True`时,json参数应该为`[]`格式。
```python
from flask import Flask, jsonify
from pyverified import rule, message, ValidationError
from pyverified.frame.flask import with_request, Params
app = Flask(__name__)
message.english()
relus = dict(
username=rule.str(required=True, isalnum=True, minLength=1, maxLength=20),
password=rule.str(required=True, isalnum=True, minLength=1, maxLength=20)
)
@app.route('/index', methods=['POST'])
@with_request(json=relus, many=True)
def index(params: Params):
return params.json
...
```
- 获取query参数并解析。
```python
from flask import Flask
from pyverified import rule, message
from pyverified.frame.flask import with_request, Params
app = Flask(__name__)
message.english()
relus = dict(
username=rule.str(required=True, isalnum=True, minLength=1, maxLength=20),
password=rule.str(required=True, isalnum=True, minLength=1, maxLength=20)
)
@app.route('/index', methods=['POST'])
@with_request(query=relus)
def index(params: Params):
return params.query
...
```
- 获取headers对应值并解析。
```python
from flask import Flask
from pyverified import rule, message
from pyverified.frame.flask import with_request, Params
app = Flask(__name__)
message.english()
relus = dict(
username=rule.str(required=True, isalnum=True, minLength=1, maxLength=20),
password=rule.str(required=True, isalnum=True, minLength=1, maxLength=20)
)
@app.route('/index', methods=['POST'])
@with_request(headers=relus)
def index(params: Params):
return params.headers
...
```
- 也支持多次解析不同的规则,但是解析相同类型的参数的话,后者会覆盖前者的解析结果
写法上可以这样写
```python
from flask import Flask
from pyverified import rule, message
from pyverified.frame.flask import with_request, Params
app = Flask(__name__)
message.english()
query_rules = dict(
username=rule.str(required=True, isalnum=True, minLength=1, maxLength=20),
password=rule.str(required=True, isalnum=True, minLength=1, maxLength=20)
)
json_rules = dict(age=rule.int(required=True))
@app.route('/index', methods=['POST'])
@with_request(query=query_rules, json=json_rules)
def index(params: Params):
return {'query': params.query, 'json': params.json}
...
```
也可以这样写
```python
from flask import Flask
from pyverified import rule, message
from pyverified.frame.flask import with_request, Params
app = Flask(__name__)
message.english()
query_rules = dict(
username=rule.str(required=True, isalnum=True, minLength=1, maxLength=20),
password=rule.str(required=True, isalnum=True, minLength=1, maxLength=20)
)
json_rules = dict(age=rule.int(required=True))
@app.route('/index', methods=['POST'])
@with_request(query=query_rules)
@with_request(json=json_rules)
def index(params: Params):
return {'query': params.query, 'json': params.json}
...
```
### Fastapi
- 获取form参数并解析
```python
from fastapi import FastAPI, Request
from starlette.responses import JSONResponse
from pyverified import rule, message, ValidationError
from pyverified.frame.fastapi import with_request
message.english()
relus = dict(
username=rule.str(required=True, isalnum=True, minLength=1, maxLength=20),
password=rule.str(required=True, isalnum=True, minLength=1, maxLength=20)
)
app = FastAPI()
@app.exception_handler(ValidationError)
async def http_exception_handler(request: Request, exc: ValidationError):
return JSONResponse(
status_code=400,
content={"message": exc.msg}
)
@app.post("/index")
@with_request(form=relus)
def index(request: Request):
params = request.state.params
return params.form
```
## 类型以及校验规则
### 基本数据类型规则
#### str
| 规则 | 释义 | 初始值 |
|--------------|-----------------------------------------------------------------------------------------------|-------|
| default | 默认值 | False |
| required | 是否是必须的 | False |
| allow_none | 值是否允许为空 | True |
| multi | 是否是多个值 | False |
| func | 自定义函数 | None |
| minLength | 字符串最小长度 | None |
| maxLength | 字符串最大长度 | None |
| enum | 字符串枚举,传入list规则时,则判断是否在枚举范围内,传入dict规则之后会对在其中的枚举进行映射 | None |
| strip | 是否去除左右两边指定字符串 | False |
| lstrip | 是否去除左边空指定字符串 | False |
| rstrip | 是否去除右边空指定字符串 | False |
| strip_chars | 配合strip使用,为指定的字符串 | None |
| lstrip_chars | 配合lstrip使用,为指定的字符串 | None |
| rstrip_chars | 配合rstrip使用,为指定的字符串 | None |
| startswith | 检字符串是否以指定字符串开头 | None |
| endswith | 检字符串是否以定字符串结尾 | None |
| isalnum | 检查字符串是否由字母和数字组成 | False |
| isalpha | 检查字符串是否仅由字母组成 | False |
| isdecimal | 检查字符串是否只包含十进制数字字符 | False |
| isdigit | 检查字符串是否只包含数字字符 | False |
| isidentifier | 检查字符串是否是一个合法的标识符 | False |
| islower | 检查字符串中的字母是否都为小写字母 | False |
| isupper | 检查字符串中的字母是否都为大写字母 | False |
| isprintable | 检查字符串是否是可打印的 | False |
| isspace | 检查字符串是否只包含空白字符 | False |
| istitle | 检查字符串中的单词是否都以大写字母开头,并且后续的字母都是小写字母 | False |
| include | 检查字符串是否包含指定字符串 | None |
| exclude | 检查字符串是否不包含指定字符串 | None |
| replace | 是否替换字符串中的指定字符串为其他字符串 | False |
| replace_args | 配合replace使用 | () |
| capitalize | 将字符串的第一个字符转换为大写,而将字符串中的其余字符转换为小写 | False |
| title | 将字符串中每个单词的第一个字母转换为大写,而将单词中的其余字母转换为小写 | False |
| swapcase | 交换字符串中每个字母的大小写 | False |
| lower | 将字符串中的所有字母转换为小写 | False |
| upper | 将字符串中的所有字母转换为大写 | False |
| casefold | 字符串的casefold()方法与lower()方法类似,但是更加强大。casefold()方法将字符串中的所有字符转换为小写,并且还处理了一些特殊字符,使其更适合用于不区分大小写的比较 | False |
| split | 将字符串按照指定字符切割,注意!使用此功能后获取的返回结果是list类型的数据 | None |
| split2type | 将切割后的数据中的元素都转化为指定的数据类型 | None |
| regex | 将字符串进行正则匹配 | None |
#### int
| 规则 | 释义 | 初始值 |
|---------------|---------------------------------------------------|-------|
| default | 默认值 | False |
| required | 是否是必须的 | False |
| allow_none | 值是否允许为空 | True |
| multi | 是否是多个值 | False |
| func | 自定义函数 | None |
| gt/gte/lt/lte | 数值大小比较 | None |
| enum | 数字枚举,传入list规则时,则判断是否在枚举范围内,传入dict规则之后会对在其中的枚举进行映射 | None |
#### float
| 规则 | 释义 | 初始值 |
|---------------|------------------|-------|
| default | 默认值 | False |
| required | 是否是必须的 | False |
| allow_none | 值是否允许为空 | True |
| multi | 是否是多个值 | False |
| func | 自定义函数 | None |
| gt/gte/lt/lte | 数值大小比较 | None |
| digits | float类型保留小数位数 | None |
| decimal | 是否转化为decimal数据类型 | False |
#### bool
| 规则 | 释义 | 初始值 |
|------------|------------------------------------------------------------|-------|
| default | 默认值 | False |
| required | 是否是必须的 | False |
| allow_none | 值是否允许为空 | True |
| multi | 是否是多个值 | False |
| func | 自定义函数 | None |
| convert | 是否将字符串转化为bool类型,为True时会转化字符串的True,False转化为对应的bool类型,大小写不敏感 | True |
#### datetime/date
| 规则 | 释义 | 初始值 |
|---------------|-------------|----------------------------------------------|
| default | 默认值 | False |
| required | 是否是必须的 | False |
| allow_none | 值是否允许为空 | True |
| multi | 是否是多个值 | False |
| func | 自定义函数 | None |
| fmt | 日期格式化样式 | datetime为`%Y-%m-%d %H:%M:%S`,date为`%Y-%m-%d` |
| gt/gte/lt/lte | 日期大小比较 | None |
| enum | 日期是否在指定的枚举中 | None |
### 嵌套结构数据类型
#### dict
| 规则 | 释义 | 初始值 |
|------------|---------------|-------|
| default | 默认值 | False |
| required | 是否是必须的 | False |
| allow_none | 值是否允许为空 | True |
| multi | 是否是多个值 | False |
| func | 自定义函数 | None |
| subset | 定义的嵌套规则 | |
| dest | 忽略所有校验,直接获取原值 | |
#### list
| 规则 | 释义 | 初始值 |
|------------|---------------|-------|
| default | 默认值 | False |
| required | 是否是必须的 | False |
| allow_none | 值是否允许为空 | True |
| multi | 是否是多个值 | False |
| func | 自定义函数 | None |
| subset | 定义的嵌套规则 | |
| dest | 忽略所有校验,直接获取原值 | |
### 扩展数据类型
#### email
校验字符串是否为邮箱
| 规则 | 释义 | 初始值 |
|------------|---------|-------|
| default | 默认值 | False |
| required | 是否是必须的 | False |
| allow_none | 值是否允许为空 | True |
| multi | 是否是多个值 | False |
| func | 自定义函数 | None |
#### ipv4
校验字符串是否为ipv4地址
| 规则 | 释义 | 初始值 |
|------------|---------|-------|
| default | 默认值 | False |
| required | 是否是必须的 | False |
| allow_none | 值是否允许为空 | True |
| multi | 是否是多个值 | False |
| func | 自定义函数 | None |
#### ipv6
校验字符串是否为ipv6地址
| 规则 | 释义 | 初始值 |
|------------|---------|-------|
| default | 默认值 | False |
| required | 是否是必须的 | False |
| allow_none | 值是否允许为空 | True |
| multi | 是否是多个值 | False |
| func | 自定义函数 | None |
#### phone
校验字符串是否为电话号码
| 规则 | 释义 | 初始值 |
|------------|---------|-------|
| default | 默认值 | False |
| required | 是否是必须的 | False |
| allow_none | 值是否允许为空 | True |
| multi | 是否是多个值 | False |
| func | 自定义函数 | None |
| region | 电话号码地区 | CN |
#### addr
校验字符串是否为链接地址
| 规则 | 释义 | 初始值 |
|------------|---------|-------|
| default | 默认值 | False |
| required | 是否是必须的 | False |
| allow_none | 值是否允许为空 | True |
| multi | 是否是多个值 | False |
| func | 自定义函数 | None |
Raw data
{
"_id": null,
"home_page": "https://github.com/xccx0823/pyverified",
"name": "pyverified",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "Ethan",
"author_email": "cheerxiong0823@163.com",
"download_url": "https://files.pythonhosted.org/packages/cf/4f/cedd83603264a5be38945efadd5da6a3555eb1213605d785581799e0dc7c/pyverified-2024.10.11.tar.gz",
"platform": null,
"description": "<p align=\"center\">\n <em>\u57fa\u4e8ePython\u5b9e\u73b0\u7684\u53c2\u6570\u6821\u9a8c\u6846\u67b6</em>\n</p>\n<p align=\"center\">\n<a href=\"#\" target=\"_blank\">\n <img src=\"https://img.shields.io/badge/python-3.6+-blue.svg\" alt=\"Python 3.6+\">\n</a>\n<a href=\"https://opensource.org/licenses/MIT\" target=\"_blank\">\n <img src=\"https://img.shields.io/badge/license-MIT-brightgreen.svg\" alt=\"MIT license\">\n</a>\n<a href=\"https://github.com/xccx0823/pyverified/releases\" target=\"_blank\">\n <img src=\"https://img.shields.io/github/v/release/xccx0823/pyverified\" alt=\"GitHub release\">\n</a>\n</p>\n\n## \u7d22\u5f15\n\n* [\u6821\u9a8c\u5931\u8d25\u6d88\u606f\u652f\u6301](#\u6821\u9a8c\u5931\u8d25\u6d88\u606f\u652f\u6301)\n* [\u6846\u67b6\u652f\u6301](#\u6846\u67b6\u652f\u6301)\n* [\u7c7b\u578b\u4ee5\u53ca\u6821\u9a8c\u89c4\u5219](#\u7c7b\u578b\u4ee5\u53ca\u6821\u9a8c\u89c4\u5219)\n\n## \u5b89\u88c5\n\n```shell\npip install pyverified\n```\n\n## \u4f7f\u7528\n\n\u5982\u4f55\u4f7f\u7528`pyverified`\u6821\u9a8c\u6570\u636e\n\n```python\nfrom pyverified import Verify, rule\n\nparams = dict(aaa=rule.float(default=1.23, digits=1))\ndata = {}\nverified = Verify(data, params)\nprint(verified.params)\n```\n\n## \u6821\u9a8c\u5931\u8d25\u6d88\u606f\u652f\u6301\n\n### \u5982\u4f55\u6539\u53d8\u62a5\u9519\u8fd4\u56de\u7684\u4fe1\u606f\n\n- \u9ed8\u8ba4\u4e3a\u4e2d\u6587\u62a5\u9519\u4fe1\u606f\uff0c\u5982\u679c\u60f3\u4f7f\u7528\u82f1\u6587\uff0c\u5219\u4f7f\u7528`message.english()`\u65b9\u6cd5\u8bbe\u7f6e\u3002\n\n```python\nfrom pyverified import rule\nfrom pyverified.msg import message\n\nmessage.english()\n\nrule.phone().execute_parse('tel', '123456')\n```\n\n- \u81ea\u5b9a\u4e49\u62a5\u9519\u4fe1\u606f\n\n```python\nfrom pyverified import rule\nfrom pyverified.msg import message\n\n\nclass NewMsg:\n phone = '{key}\u7684\u503c{value}\u5e76\u4e0d\u662f\u7535\u8bdd\u53f7\u7801'\n\n\nmessage.reload(NewMsg)\n\nrule.phone().execute_parse('tel', '123456')\n```\n\n## \u6846\u67b6\u652f\u6301\n\n### Flask\n\n- \u83b7\u53d6form\u53c2\u6570\u5e76\u89e3\u6790\n\n```python\nfrom flask import Flask, jsonify\n\nfrom pyverified import rule, message, ValidationError\nfrom pyverified.frame.flask import with_request, Params\n\napp = Flask(__name__)\nmessage.english()\n\nrelus = dict(\n username=rule.str(required=True, isalnum=True, minLength=1, maxLength=20),\n password=rule.str(required=True, isalnum=True, minLength=1, maxLength=20)\n)\n\n\n# \u62e6\u622a pyverified \u7684 ValidationError \u5f02\u5e38\uff0c\u5b9a\u5236\u8fd4\u56de\u6d88\u606f\u683c\u5f0f\u3002\n@app.errorhandler(ValidationError)\ndef handler_exception(error):\n response = jsonify({'error': error.msg})\n response.status_code = 400\n return response\n\n\n@app.route('/index', methods=['POST'])\n@with_request(form=relus) # \u5fc5\u987b\u5728 app.route \u88c5\u9970\u5668\u4e0b\u9762\ndef index(params: Params):\n return params.form\n\n\nif __name__ == '__main__':\n app.run()\n```\n\n- \u83b7\u53d6json\u53c2\u6570\u5e76\u89e3\u6790\uff0c\u5f53\u8bbe\u7f6e`many=True`\u65f6\uff0cjson\u53c2\u6570\u5e94\u8be5\u4e3a`[]`\u683c\u5f0f\u3002\n\n```python\nfrom flask import Flask, jsonify\n\nfrom pyverified import rule, message, ValidationError\nfrom pyverified.frame.flask import with_request, Params\n\napp = Flask(__name__)\nmessage.english()\n\nrelus = dict(\n username=rule.str(required=True, isalnum=True, minLength=1, maxLength=20),\n password=rule.str(required=True, isalnum=True, minLength=1, maxLength=20)\n)\n\n\n@app.route('/index', methods=['POST'])\n@with_request(json=relus, many=True)\ndef index(params: Params):\n return params.json\n\n\n...\n```\n\n- \u83b7\u53d6query\u53c2\u6570\u5e76\u89e3\u6790\u3002\n\n```python\nfrom flask import Flask\n\nfrom pyverified import rule, message\nfrom pyverified.frame.flask import with_request, Params\n\napp = Flask(__name__)\nmessage.english()\n\nrelus = dict(\n username=rule.str(required=True, isalnum=True, minLength=1, maxLength=20),\n password=rule.str(required=True, isalnum=True, minLength=1, maxLength=20)\n)\n\n\n@app.route('/index', methods=['POST'])\n@with_request(query=relus)\ndef index(params: Params):\n return params.query\n\n\n...\n```\n\n- \u83b7\u53d6headers\u5bf9\u5e94\u503c\u5e76\u89e3\u6790\u3002\n\n```python\nfrom flask import Flask\n\nfrom pyverified import rule, message\nfrom pyverified.frame.flask import with_request, Params\n\napp = Flask(__name__)\nmessage.english()\n\nrelus = dict(\n username=rule.str(required=True, isalnum=True, minLength=1, maxLength=20),\n password=rule.str(required=True, isalnum=True, minLength=1, maxLength=20)\n)\n\n\n@app.route('/index', methods=['POST'])\n@with_request(headers=relus)\ndef index(params: Params):\n return params.headers\n\n\n...\n```\n\n- \u4e5f\u652f\u6301\u591a\u6b21\u89e3\u6790\u4e0d\u540c\u7684\u89c4\u5219\uff0c\u4f46\u662f\u89e3\u6790\u76f8\u540c\u7c7b\u578b\u7684\u53c2\u6570\u7684\u8bdd\uff0c\u540e\u8005\u4f1a\u8986\u76d6\u524d\u8005\u7684\u89e3\u6790\u7ed3\u679c\n\n\u5199\u6cd5\u4e0a\u53ef\u4ee5\u8fd9\u6837\u5199\n\n```python\nfrom flask import Flask\n\nfrom pyverified import rule, message\nfrom pyverified.frame.flask import with_request, Params\n\napp = Flask(__name__)\nmessage.english()\n\nquery_rules = dict(\n username=rule.str(required=True, isalnum=True, minLength=1, maxLength=20),\n password=rule.str(required=True, isalnum=True, minLength=1, maxLength=20)\n)\njson_rules = dict(age=rule.int(required=True))\n\n\n@app.route('/index', methods=['POST'])\n@with_request(query=query_rules, json=json_rules)\ndef index(params: Params):\n return {'query': params.query, 'json': params.json}\n\n\n...\n```\n\n\u4e5f\u53ef\u4ee5\u8fd9\u6837\u5199\n\n```python\nfrom flask import Flask\n\nfrom pyverified import rule, message\nfrom pyverified.frame.flask import with_request, Params\n\napp = Flask(__name__)\nmessage.english()\n\nquery_rules = dict(\n username=rule.str(required=True, isalnum=True, minLength=1, maxLength=20),\n password=rule.str(required=True, isalnum=True, minLength=1, maxLength=20)\n)\njson_rules = dict(age=rule.int(required=True))\n\n\n@app.route('/index', methods=['POST'])\n@with_request(query=query_rules)\n@with_request(json=json_rules)\ndef index(params: Params):\n return {'query': params.query, 'json': params.json}\n\n\n...\n```\n\n### Fastapi\n\n- \u83b7\u53d6form\u53c2\u6570\u5e76\u89e3\u6790\n\n```python\nfrom fastapi import FastAPI, Request\nfrom starlette.responses import JSONResponse\n\nfrom pyverified import rule, message, ValidationError\nfrom pyverified.frame.fastapi import with_request\n\nmessage.english()\n\nrelus = dict(\n username=rule.str(required=True, isalnum=True, minLength=1, maxLength=20),\n password=rule.str(required=True, isalnum=True, minLength=1, maxLength=20)\n)\n\napp = FastAPI()\n\n\n@app.exception_handler(ValidationError)\nasync def http_exception_handler(request: Request, exc: ValidationError):\n return JSONResponse(\n status_code=400,\n content={\"message\": exc.msg}\n )\n\n\n@app.post(\"/index\")\n@with_request(form=relus)\ndef index(request: Request):\n params = request.state.params\n return params.form\n```\n\n## \u7c7b\u578b\u4ee5\u53ca\u6821\u9a8c\u89c4\u5219\n\n### \u57fa\u672c\u6570\u636e\u7c7b\u578b\u89c4\u5219\n\n#### str\n\n| \u89c4\u5219 | \u91ca\u4e49 | \u521d\u59cb\u503c |\n|--------------|-----------------------------------------------------------------------------------------------|-------|\n| default | \u9ed8\u8ba4\u503c | False |\n| required | \u662f\u5426\u662f\u5fc5\u987b\u7684 | False |\n| allow_none | \u503c\u662f\u5426\u5141\u8bb8\u4e3a\u7a7a | True |\n| multi | \u662f\u5426\u662f\u591a\u4e2a\u503c | False |\n| func | \u81ea\u5b9a\u4e49\u51fd\u6570 | None |\n| minLength | \u5b57\u7b26\u4e32\u6700\u5c0f\u957f\u5ea6 | None |\n| maxLength | \u5b57\u7b26\u4e32\u6700\u5927\u957f\u5ea6 | None |\n| enum | \u5b57\u7b26\u4e32\u679a\u4e3e\uff0c\u4f20\u5165list\u89c4\u5219\u65f6\uff0c\u5219\u5224\u65ad\u662f\u5426\u5728\u679a\u4e3e\u8303\u56f4\u5185\uff0c\u4f20\u5165dict\u89c4\u5219\u4e4b\u540e\u4f1a\u5bf9\u5728\u5176\u4e2d\u7684\u679a\u4e3e\u8fdb\u884c\u6620\u5c04 | None |\n| strip | \u662f\u5426\u53bb\u9664\u5de6\u53f3\u4e24\u8fb9\u6307\u5b9a\u5b57\u7b26\u4e32 | False |\n| lstrip | \u662f\u5426\u53bb\u9664\u5de6\u8fb9\u7a7a\u6307\u5b9a\u5b57\u7b26\u4e32 | False |\n| rstrip | \u662f\u5426\u53bb\u9664\u53f3\u8fb9\u7a7a\u6307\u5b9a\u5b57\u7b26\u4e32 | False |\n| strip_chars | \u914d\u5408strip\u4f7f\u7528\uff0c\u4e3a\u6307\u5b9a\u7684\u5b57\u7b26\u4e32 | None |\n| lstrip_chars | \u914d\u5408lstrip\u4f7f\u7528\uff0c\u4e3a\u6307\u5b9a\u7684\u5b57\u7b26\u4e32 | None |\n| rstrip_chars | \u914d\u5408rstrip\u4f7f\u7528\uff0c\u4e3a\u6307\u5b9a\u7684\u5b57\u7b26\u4e32 | None |\n| startswith | \u68c0\u5b57\u7b26\u4e32\u662f\u5426\u4ee5\u6307\u5b9a\u5b57\u7b26\u4e32\u5f00\u5934 | None |\n| endswith | \u68c0\u5b57\u7b26\u4e32\u662f\u5426\u4ee5\u5b9a\u5b57\u7b26\u4e32\u7ed3\u5c3e | None |\n| isalnum | \u68c0\u67e5\u5b57\u7b26\u4e32\u662f\u5426\u7531\u5b57\u6bcd\u548c\u6570\u5b57\u7ec4\u6210 | False |\n| isalpha | \u68c0\u67e5\u5b57\u7b26\u4e32\u662f\u5426\u4ec5\u7531\u5b57\u6bcd\u7ec4\u6210 | False |\n| isdecimal | \u68c0\u67e5\u5b57\u7b26\u4e32\u662f\u5426\u53ea\u5305\u542b\u5341\u8fdb\u5236\u6570\u5b57\u5b57\u7b26 | False |\n| isdigit | \u68c0\u67e5\u5b57\u7b26\u4e32\u662f\u5426\u53ea\u5305\u542b\u6570\u5b57\u5b57\u7b26 | False |\n| isidentifier | \u68c0\u67e5\u5b57\u7b26\u4e32\u662f\u5426\u662f\u4e00\u4e2a\u5408\u6cd5\u7684\u6807\u8bc6\u7b26 | False |\n| islower | \u68c0\u67e5\u5b57\u7b26\u4e32\u4e2d\u7684\u5b57\u6bcd\u662f\u5426\u90fd\u4e3a\u5c0f\u5199\u5b57\u6bcd | False |\n| isupper | \u68c0\u67e5\u5b57\u7b26\u4e32\u4e2d\u7684\u5b57\u6bcd\u662f\u5426\u90fd\u4e3a\u5927\u5199\u5b57\u6bcd | False |\n| isprintable | \u68c0\u67e5\u5b57\u7b26\u4e32\u662f\u5426\u662f\u53ef\u6253\u5370\u7684 | False |\n| isspace | \u68c0\u67e5\u5b57\u7b26\u4e32\u662f\u5426\u53ea\u5305\u542b\u7a7a\u767d\u5b57\u7b26 | False |\n| istitle | \u68c0\u67e5\u5b57\u7b26\u4e32\u4e2d\u7684\u5355\u8bcd\u662f\u5426\u90fd\u4ee5\u5927\u5199\u5b57\u6bcd\u5f00\u5934\uff0c\u5e76\u4e14\u540e\u7eed\u7684\u5b57\u6bcd\u90fd\u662f\u5c0f\u5199\u5b57\u6bcd | False |\n| include | \u68c0\u67e5\u5b57\u7b26\u4e32\u662f\u5426\u5305\u542b\u6307\u5b9a\u5b57\u7b26\u4e32 | None |\n| exclude | \u68c0\u67e5\u5b57\u7b26\u4e32\u662f\u5426\u4e0d\u5305\u542b\u6307\u5b9a\u5b57\u7b26\u4e32 | None |\n| replace | \u662f\u5426\u66ff\u6362\u5b57\u7b26\u4e32\u4e2d\u7684\u6307\u5b9a\u5b57\u7b26\u4e32\u4e3a\u5176\u4ed6\u5b57\u7b26\u4e32 | False |\n| replace_args | \u914d\u5408replace\u4f7f\u7528 | () |\n| capitalize | \u5c06\u5b57\u7b26\u4e32\u7684\u7b2c\u4e00\u4e2a\u5b57\u7b26\u8f6c\u6362\u4e3a\u5927\u5199\uff0c\u800c\u5c06\u5b57\u7b26\u4e32\u4e2d\u7684\u5176\u4f59\u5b57\u7b26\u8f6c\u6362\u4e3a\u5c0f\u5199 | False |\n| title | \u5c06\u5b57\u7b26\u4e32\u4e2d\u6bcf\u4e2a\u5355\u8bcd\u7684\u7b2c\u4e00\u4e2a\u5b57\u6bcd\u8f6c\u6362\u4e3a\u5927\u5199\uff0c\u800c\u5c06\u5355\u8bcd\u4e2d\u7684\u5176\u4f59\u5b57\u6bcd\u8f6c\u6362\u4e3a\u5c0f\u5199 | False |\n| swapcase | \u4ea4\u6362\u5b57\u7b26\u4e32\u4e2d\u6bcf\u4e2a\u5b57\u6bcd\u7684\u5927\u5c0f\u5199 | False |\n| lower | \u5c06\u5b57\u7b26\u4e32\u4e2d\u7684\u6240\u6709\u5b57\u6bcd\u8f6c\u6362\u4e3a\u5c0f\u5199 | False |\n| upper | \u5c06\u5b57\u7b26\u4e32\u4e2d\u7684\u6240\u6709\u5b57\u6bcd\u8f6c\u6362\u4e3a\u5927\u5199 | False |\n| casefold | \u5b57\u7b26\u4e32\u7684casefold()\u65b9\u6cd5\u4e0elower()\u65b9\u6cd5\u7c7b\u4f3c\uff0c\u4f46\u662f\u66f4\u52a0\u5f3a\u5927\u3002casefold()\u65b9\u6cd5\u5c06\u5b57\u7b26\u4e32\u4e2d\u7684\u6240\u6709\u5b57\u7b26\u8f6c\u6362\u4e3a\u5c0f\u5199\uff0c\u5e76\u4e14\u8fd8\u5904\u7406\u4e86\u4e00\u4e9b\u7279\u6b8a\u5b57\u7b26\uff0c\u4f7f\u5176\u66f4\u9002\u5408\u7528\u4e8e\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u7684\u6bd4\u8f83 | False |\n| split | \u5c06\u5b57\u7b26\u4e32\u6309\u7167\u6307\u5b9a\u5b57\u7b26\u5207\u5272\uff0c\u6ce8\u610f\uff01\u4f7f\u7528\u6b64\u529f\u80fd\u540e\u83b7\u53d6\u7684\u8fd4\u56de\u7ed3\u679c\u662flist\u7c7b\u578b\u7684\u6570\u636e | None |\n| split2type | \u5c06\u5207\u5272\u540e\u7684\u6570\u636e\u4e2d\u7684\u5143\u7d20\u90fd\u8f6c\u5316\u4e3a\u6307\u5b9a\u7684\u6570\u636e\u7c7b\u578b | None |\n| regex | \u5c06\u5b57\u7b26\u4e32\u8fdb\u884c\u6b63\u5219\u5339\u914d | None |\n\n#### int\n\n| \u89c4\u5219 | \u91ca\u4e49 | \u521d\u59cb\u503c |\n|---------------|---------------------------------------------------|-------|\n| default | \u9ed8\u8ba4\u503c | False |\n| required | \u662f\u5426\u662f\u5fc5\u987b\u7684 | False |\n| allow_none | \u503c\u662f\u5426\u5141\u8bb8\u4e3a\u7a7a | True |\n| multi | \u662f\u5426\u662f\u591a\u4e2a\u503c | False |\n| func | \u81ea\u5b9a\u4e49\u51fd\u6570 | None |\n| gt/gte/lt/lte | \u6570\u503c\u5927\u5c0f\u6bd4\u8f83 | None |\n| enum | \u6570\u5b57\u679a\u4e3e\uff0c\u4f20\u5165list\u89c4\u5219\u65f6\uff0c\u5219\u5224\u65ad\u662f\u5426\u5728\u679a\u4e3e\u8303\u56f4\u5185\uff0c\u4f20\u5165dict\u89c4\u5219\u4e4b\u540e\u4f1a\u5bf9\u5728\u5176\u4e2d\u7684\u679a\u4e3e\u8fdb\u884c\u6620\u5c04 | None |\n\n#### float\n\n| \u89c4\u5219 | \u91ca\u4e49 | \u521d\u59cb\u503c |\n|---------------|------------------|-------|\n| default | \u9ed8\u8ba4\u503c | False |\n| required | \u662f\u5426\u662f\u5fc5\u987b\u7684 | False |\n| allow_none | \u503c\u662f\u5426\u5141\u8bb8\u4e3a\u7a7a | True |\n| multi | \u662f\u5426\u662f\u591a\u4e2a\u503c | False |\n| func | \u81ea\u5b9a\u4e49\u51fd\u6570 | None |\n| gt/gte/lt/lte | \u6570\u503c\u5927\u5c0f\u6bd4\u8f83 | None |\n| digits | float\u7c7b\u578b\u4fdd\u7559\u5c0f\u6570\u4f4d\u6570 | None |\n| decimal | \u662f\u5426\u8f6c\u5316\u4e3adecimal\u6570\u636e\u7c7b\u578b | False |\n\n#### bool\n\n| \u89c4\u5219 | \u91ca\u4e49 | \u521d\u59cb\u503c |\n|------------|------------------------------------------------------------|-------|\n| default | \u9ed8\u8ba4\u503c | False |\n| required | \u662f\u5426\u662f\u5fc5\u987b\u7684 | False |\n| allow_none | \u503c\u662f\u5426\u5141\u8bb8\u4e3a\u7a7a | True |\n| multi | \u662f\u5426\u662f\u591a\u4e2a\u503c | False |\n| func | \u81ea\u5b9a\u4e49\u51fd\u6570 | None |\n| convert | \u662f\u5426\u5c06\u5b57\u7b26\u4e32\u8f6c\u5316\u4e3abool\u7c7b\u578b\uff0c\u4e3aTrue\u65f6\u4f1a\u8f6c\u5316\u5b57\u7b26\u4e32\u7684True\uff0cFalse\u8f6c\u5316\u4e3a\u5bf9\u5e94\u7684bool\u7c7b\u578b\uff0c\u5927\u5c0f\u5199\u4e0d\u654f\u611f | True |\n\n#### datetime/date\n\n| \u89c4\u5219 | \u91ca\u4e49 | \u521d\u59cb\u503c |\n|---------------|-------------|----------------------------------------------|\n| default | \u9ed8\u8ba4\u503c | False |\n| required | \u662f\u5426\u662f\u5fc5\u987b\u7684 | False |\n| allow_none | \u503c\u662f\u5426\u5141\u8bb8\u4e3a\u7a7a | True |\n| multi | \u662f\u5426\u662f\u591a\u4e2a\u503c | False |\n| func | \u81ea\u5b9a\u4e49\u51fd\u6570 | None |\n| fmt | \u65e5\u671f\u683c\u5f0f\u5316\u6837\u5f0f | datetime\u4e3a`%Y-%m-%d %H:%M:%S`\uff0cdate\u4e3a`%Y-%m-%d` |\n| gt/gte/lt/lte | \u65e5\u671f\u5927\u5c0f\u6bd4\u8f83 | None |\n| enum | \u65e5\u671f\u662f\u5426\u5728\u6307\u5b9a\u7684\u679a\u4e3e\u4e2d | None |\n\n### \u5d4c\u5957\u7ed3\u6784\u6570\u636e\u7c7b\u578b\n\n#### dict\n\n| \u89c4\u5219 | \u91ca\u4e49 | \u521d\u59cb\u503c |\n|------------|---------------|-------|\n| default | \u9ed8\u8ba4\u503c | False |\n| required | \u662f\u5426\u662f\u5fc5\u987b\u7684 | False |\n| allow_none | \u503c\u662f\u5426\u5141\u8bb8\u4e3a\u7a7a | True |\n| multi | \u662f\u5426\u662f\u591a\u4e2a\u503c | False |\n| func | \u81ea\u5b9a\u4e49\u51fd\u6570 | None |\n| subset | \u5b9a\u4e49\u7684\u5d4c\u5957\u89c4\u5219 | |\n| dest | \u5ffd\u7565\u6240\u6709\u6821\u9a8c\uff0c\u76f4\u63a5\u83b7\u53d6\u539f\u503c | |\n\n#### list\n\n| \u89c4\u5219 | \u91ca\u4e49 | \u521d\u59cb\u503c |\n|------------|---------------|-------|\n| default | \u9ed8\u8ba4\u503c | False |\n| required | \u662f\u5426\u662f\u5fc5\u987b\u7684 | False |\n| allow_none | \u503c\u662f\u5426\u5141\u8bb8\u4e3a\u7a7a | True |\n| multi | \u662f\u5426\u662f\u591a\u4e2a\u503c | False |\n| func | \u81ea\u5b9a\u4e49\u51fd\u6570 | None |\n| subset | \u5b9a\u4e49\u7684\u5d4c\u5957\u89c4\u5219 | |\n| dest | \u5ffd\u7565\u6240\u6709\u6821\u9a8c\uff0c\u76f4\u63a5\u83b7\u53d6\u539f\u503c | |\n\n### \u6269\u5c55\u6570\u636e\u7c7b\u578b\n\n#### email\n\n\u6821\u9a8c\u5b57\u7b26\u4e32\u662f\u5426\u4e3a\u90ae\u7bb1\n\n| \u89c4\u5219 | \u91ca\u4e49 | \u521d\u59cb\u503c |\n|------------|---------|-------|\n| default | \u9ed8\u8ba4\u503c | False |\n| required | \u662f\u5426\u662f\u5fc5\u987b\u7684 | False |\n| allow_none | \u503c\u662f\u5426\u5141\u8bb8\u4e3a\u7a7a | True |\n| multi | \u662f\u5426\u662f\u591a\u4e2a\u503c | False |\n| func | \u81ea\u5b9a\u4e49\u51fd\u6570 | None |\n\n#### ipv4\n\n\u6821\u9a8c\u5b57\u7b26\u4e32\u662f\u5426\u4e3aipv4\u5730\u5740\n\n| \u89c4\u5219 | \u91ca\u4e49 | \u521d\u59cb\u503c |\n|------------|---------|-------|\n| default | \u9ed8\u8ba4\u503c | False |\n| required | \u662f\u5426\u662f\u5fc5\u987b\u7684 | False |\n| allow_none | \u503c\u662f\u5426\u5141\u8bb8\u4e3a\u7a7a | True |\n| multi | \u662f\u5426\u662f\u591a\u4e2a\u503c | False |\n| func | \u81ea\u5b9a\u4e49\u51fd\u6570 | None |\n\n#### ipv6\n\n\u6821\u9a8c\u5b57\u7b26\u4e32\u662f\u5426\u4e3aipv6\u5730\u5740\n\n| \u89c4\u5219 | \u91ca\u4e49 | \u521d\u59cb\u503c |\n|------------|---------|-------|\n| default | \u9ed8\u8ba4\u503c | False |\n| required | \u662f\u5426\u662f\u5fc5\u987b\u7684 | False |\n| allow_none | \u503c\u662f\u5426\u5141\u8bb8\u4e3a\u7a7a | True |\n| multi | \u662f\u5426\u662f\u591a\u4e2a\u503c | False |\n| func | \u81ea\u5b9a\u4e49\u51fd\u6570 | None |\n\n#### phone\n\n\u6821\u9a8c\u5b57\u7b26\u4e32\u662f\u5426\u4e3a\u7535\u8bdd\u53f7\u7801\n\n| \u89c4\u5219 | \u91ca\u4e49 | \u521d\u59cb\u503c |\n|------------|---------|-------|\n| default | \u9ed8\u8ba4\u503c | False |\n| required | \u662f\u5426\u662f\u5fc5\u987b\u7684 | False |\n| allow_none | \u503c\u662f\u5426\u5141\u8bb8\u4e3a\u7a7a | True |\n| multi | \u662f\u5426\u662f\u591a\u4e2a\u503c | False |\n| func | \u81ea\u5b9a\u4e49\u51fd\u6570 | None |\n| region | \u7535\u8bdd\u53f7\u7801\u5730\u533a | CN |\n\n#### addr\n\n\u6821\u9a8c\u5b57\u7b26\u4e32\u662f\u5426\u4e3a\u94fe\u63a5\u5730\u5740\n\n| \u89c4\u5219 | \u91ca\u4e49 | \u521d\u59cb\u503c |\n|------------|---------|-------|\n| default | \u9ed8\u8ba4\u503c | False |\n| required | \u662f\u5426\u662f\u5fc5\u987b\u7684 | False |\n| allow_none | \u503c\u662f\u5426\u5141\u8bb8\u4e3a\u7a7a | True |\n| multi | \u662f\u5426\u662f\u591a\u4e2a\u503c | False |\n| func | \u81ea\u5b9a\u4e49\u51fd\u6570 | None |\n\n\n",
"bugtrack_url": null,
"license": null,
"summary": "Parameter verification framework based on Python.",
"version": "2024.10.11",
"project_urls": {
"Homepage": "https://github.com/xccx0823/pyverified"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "39a4a5f2a82009d17e832f20c4a5d030faa78717b9f161613ccd72c8c0257935",
"md5": "76e2d013a804c40807fcaa723020c70c",
"sha256": "155c87ac9800a180a3107dccc64ebf4774d8a05755981b4c79c90532cbc20542"
},
"downloads": -1,
"filename": "pyverified-2024.10.11-py3-none-any.whl",
"has_sig": false,
"md5_digest": "76e2d013a804c40807fcaa723020c70c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 16566,
"upload_time": "2024-10-11T02:07:02",
"upload_time_iso_8601": "2024-10-11T02:07:02.932271Z",
"url": "https://files.pythonhosted.org/packages/39/a4/a5f2a82009d17e832f20c4a5d030faa78717b9f161613ccd72c8c0257935/pyverified-2024.10.11-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "cf4fcedd83603264a5be38945efadd5da6a3555eb1213605d785581799e0dc7c",
"md5": "2203b3f5dfdc7e5b9d1bfb09bfcd3b51",
"sha256": "00664b44d208f802142793da67ec2391a937849616ab3f5594b944e262336fa5"
},
"downloads": -1,
"filename": "pyverified-2024.10.11.tar.gz",
"has_sig": false,
"md5_digest": "2203b3f5dfdc7e5b9d1bfb09bfcd3b51",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 16812,
"upload_time": "2024-10-11T02:07:04",
"upload_time_iso_8601": "2024-10-11T02:07:04.987098Z",
"url": "https://files.pythonhosted.org/packages/cf/4f/cedd83603264a5be38945efadd5da6a3555eb1213605d785581799e0dc7c/pyverified-2024.10.11.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-11 02:07:04",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "xccx0823",
"github_project": "pyverified",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "phonenumbers",
"specs": [
[
"==",
"8.13.25"
]
]
}
],
"lcname": "pyverified"
}