Decorator for Django REST Framework for validate params
Project description
django-params-validator
django restframe params validator
use for check django rest api params 用于检查django的rest接口的参数 包括参数的类型、范围 如果参数是bool类型,能将 1, 0转化为布尔值
pip install django-params-validator
Example
from django_params_validator import Params
@Params(book_num=int, book_num__gte=100, book_num__lte=200, book__optional=False)
def some_interface(request, *args, **kwargs):
pass
@Params(name=str, name__default='jack',
create_datetime=Params.DATETIME_STR, create_datetime__format='%Y-%m-%d',
colors=('red', 'blue', 'yellow'), colors__many=True)
def other_interface(request, *args, **kwargs):
colors = kwargs.get('colors')
# colors = ['']
pass
Options
TYPE
name=str
指定参数的类型
其中Params.DATETIME_STR是特殊的时间戳字符串格式
gt/lt/gte/lte
制定参数的范围
num__gte=100
optional
是否是可选参数
default
默认值
many
colors__many=True
是否是列表。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for django-params-validator-1.1.9.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b729c6539eaaa3db45e165cd9b3620f775007eec7f14446c68e40155a2011d80 |
|
MD5 | df94db489f3de33468c392b2ec166e37 |
|
BLAKE2b-256 | e7fa98d770de14be35e70c1baa1ce3004cac0649deee71efab4572e75b592d48 |