elasticsales/flask-mongorest — pull request #4 by lucasvo (2012-08-23 19:58:49+00:00)
Title: Form Validation of None Values

It's not the prettiest solution but without fixing mongoengine's email validation, this will have to do

If you setup the following resource form:

```
class SomeDocument(Document):
email = EmailField(required=False)
name = StringField()

ResourceFormBase = model_form(SomeDocument, exclude=['email'])
class ResourceForm(ResourceFormBase):
email = fields.TextField(validators=[validators.optional(), validators.email()])
```

A POST with the following json: `{'name':'John Doe'}` fails without these changes.

Because form.data returns: `{'name':'John Doe', 'email':''}` instead of `{'name':'John Doe'}` which causes a validation error. There might be other consequences of this behavior.