flask-mongoengine icon indicating copy to clipboard operation
flask-mongoengine copied to clipboard

model_form doesn't validate StringField's inside ListField

Open adamlwgriffiths opened this issue 11 years ago • 1 comments

I have the following inside a document class

tags = db.ListField(db.StringField(max_length=30, min_length=1), required=True)

I use the model_form to create the form.

If I send back a tag field with no content the form.validate() function should return False. Instead, the function is returning True. It is then left to Mongo to pick up the validation error and throw an exception.

ValidationError (Post:51ad4c74c47f3e07507984f4) (3.String value is too short: ['tags'])

The form.validate() function should validate the contents of ListField's.

adamlwgriffiths avatar Jun 05 '13 05:06 adamlwgriffiths

I pushed a branch with a test for this:

https://github.com/MongoEngine/flask-mongoengine/tree/listfield_validation

lafrech avatar Feb 23 '16 11:02 lafrech