This is a request handler validation tool for RESTful API endpoints.
Project description
Validrequest
This is a request handler validation tool for RESTful API endpoints.
How To Use
from validrequest import validator, ValidationError
def request_handler(req, res, next):
# If you're familiar with Express.js req, res, next should be understood
validation_rules = get_validation_rules()
request_parameters = req.query
validation_rules = {
"q": "string|required|max:100",
"timestamp": "string|sometimes|max:30",
"names": "list|required|min:3",
"code": "integer|required|"
}
try:
validator(validation_rules, request_parameters)
except ValidationError:
return next({ "message": "The request parameters are not valid."})
res.json({"message": "Validation successful."})
Refer to the demo.py
file for further implementations.
How to Install
python -m pip install validrequest
or
python -m pip install git+https://github.com/ableinc/validrequest.git
Contributions
This library was designed and inspired by Jacob Lucas. Validator is a python rewrite of the original nodeJS library.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
validrequest-0.0.3.tar.gz
(3.3 kB
view hashes)
Built Distribution
Close
Hashes for validrequest-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bfa41fe68229d431618e8bae6ba0545cc43ee77ef7217a41edd19d0b1c430352 |
|
MD5 | bfeb395d16a9115c4d036c8bc043c68b |
|
BLAKE2b-256 | bf18d9e7333a570dd1a3f3041714d09e0a444dbd547cd8002fd4a4fe61173ea3 |