Metadata-Version: 2.4
Name: Flask-WTF-Decorators
Version: 0.1.2
Summary: Decorators for flask-wtf
Home-page: https://github.com/simpleapples/flask-wtf-decorators/
Author: Zhiya Zang
Author-email: zangzhiya@gmail.com
License: MIT
Platform: any
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: License :: OSI Approved :: MIT License
Description-Content-Type: text/markdown
License-File: LICENSE.txt
Requires-Dist: Flask>=0.7
Requires-Dist: Flask-WTF>=0.9
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license
Dynamic: license-file
Dynamic: platform
Dynamic: requires-dist
Dynamic: summary

# Flask-WTF-Decorators [![Build Status](https://travis-ci.org/simpleapples/flask-wtf-decorators.svg?branch=master)](https://travis-ci.org/simpleapples/flask-wtf-decorators)

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.
