Decorators for flask-wtf
Project description
# Flask-WTF-Decorators [![Build Status](https://travis-ci.org/simpleapples/flask-wtf-decorators.svg?branch=master)](https://travis-ci.org/simpleapples/flask-wtf-decorators) [![Coverage Status](https://coveralls.io/repos/github/simpleapples/flask-wtf-decorators/badge.svg?branch=master)](https://coveralls.io/github/simpleapples/flask-wtf-decorators?branch=master)
Using decorators to validate form.
# Installation
Using pip
`pip install flask-wtf-decorators`
Using Pipenv
`pipenv install flask-wtf-decorators`
# Usage
Flask-WTF-Decorators is easy to use. You can define a view that requires validation.
```python
from flask-wtf-decorators import FormValidator
form_validator = FormValidator()
@form_validator.validate_form(TestForm)
@app.route('/', methods=['GET', 'POST'])
def index(form):
pass
```
You can tell Flask-WTF-Decorators what to do when a form is illegal. To do this you should provide a callback for `error_handler`.
```python
@form_validator.error_handler
def error_handler(errors):
return jsonify({'errors': errors}), 400
```
# Test
`python -m unittest discover -s tests`
# Contributing
Please submit a pull request to contribute.
# License
This project is licensed under the MIT License.
Using decorators to validate form.
# Installation
Using pip
`pip install flask-wtf-decorators`
Using Pipenv
`pipenv install flask-wtf-decorators`
# Usage
Flask-WTF-Decorators is easy to use. You can define a view that requires validation.
```python
from flask-wtf-decorators import FormValidator
form_validator = FormValidator()
@form_validator.validate_form(TestForm)
@app.route('/', methods=['GET', 'POST'])
def index(form):
pass
```
You can tell Flask-WTF-Decorators what to do when a form is illegal. To do this you should provide a callback for `error_handler`.
```python
@form_validator.error_handler
def error_handler(errors):
return jsonify({'errors': errors}), 400
```
# Test
`python -m unittest discover -s tests`
# Contributing
Please submit a pull request to contribute.
# License
This project is licensed under the MIT License.
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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for Flask_WTF_Decorators-0.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b657f9b13757566d21f3f5005f01547676f41898100458141986b811cba6218f |
|
MD5 | 1a4a3ee5dbcefb953d2b6612beaaf2e1 |
|
BLAKE2b-256 | 9ae464d10f131541bae02f8585f5d9fb81bb3b44b6b1c8516811b9306ecd82ed |