前言
在校验请求参数的时候,除了一些基本的required=True, type类型外,还会遇到一些校验,比如是否为空,字符串长度,以及一些自定义的参数规则。
add_argument 参数
下面是add_argument 可以使用的参数,部分源码如下:
class Argument(object):
"""
:param name: Either a name or a list of option strings, e.g. foo or
-f, --foo.
:param default: The value produced if the argument is absent from the
request.
:param dest: The name of the attribute to be added to the object
returned by :meth:`~reqparse.RequestParser.parse_args()`.
:param bool required: Whether or not the argument may be omitted (optionals
only).
:param action: The basic type of action to be taken when this argument
is encountered in the request. Valid options are "store" and "append".
:param ignore: Whether to ignore cases where the argument fails type
conver