Adds smart json support for WTForms. Useful for when using WTForms with RESTful APIs.
If you're using forms for handling patch requests, you have to use `validators.Optional()` at the end of your validation chain for all fields. That said, the test that `validators.Optional()` uses to determine if a field is blank is different than the test that `patch_data` uses. Entering white space for a field will match `validators.Optional()`, so validations will be skipped, but the resulting `patch_dict` will contain the field still. For example: ``` python from wtforms import Form, fields, validators import wtforms_json wtforms_json.init() class PatchUserForm(Form): email = fields.TextField( 'email', [validators.Email('Invalid email address.'), validators.Optional()] ) form = PatchUserForm.from_json({'email': ' '}) assert form.validate() assert 'email' not in form.patch_data # will fail here. ``` The argument against this is that people should be able to set fields to null or blank via patch, but in that case wtforms-json could check the field's `optional` flag, yea? For my use case, I'm using a custom validator in place of `validators.Optional` that doesn't consider `' '` falsy.
This issue appears to be discussing a feature request or bug report related to the repository. Based on the content, it seems to be still under discussion. The issue was opened by larkin and has received 1 comments.