-
Notifications
You must be signed in to change notification settings - Fork 9
Notes
Danila Ganchar edited this page Aug 9, 2024
·
3 revisions
# v2
class AbstractRule(object):
def validate(self, value):
"""
:return: only errors
:rtype: list
"""
raise NotImplementedError()
# v3
class AbstractRule(object):
def validate(self, value):
"""
:return: tuple of value and errors
:rtype: tupple
"""
raise NotImplementedError()
In v3 we can use **kwargs
:
email_rules = CompositeRule(IsEmail(), MinLength(10), MaxLength(20))
params = [
Param('email', GET, str, rules=email_rules),
Param('streets', GET, list),
Param('meta', GET, dict),
)
# v2
@app.route('/person')
@validate_params(*params)
def route_one(email, streets, meta):
pass
# v3
@app.route('/person')
@validate_params(*params)
def route_one(**kwargs):
print(kwargs)
See commit