Require_keys()
Used for validating dictionaries. Used for checking that a dictionary has a set of keys. This is useful when validating the body of a request (body
). Returns False if all keys were found and True if one or more keys are missing.
Usage
require_keys(required keys, ...)
Parameters
A list.
of strings.
Example
@post('/login'):
if require_keys(['email', 'password'], body):
status('Please provide an email address and a password.', 400)
# All keys where found in the request JSON body.
...
Last updated