powmedia / backbone-forms

Form framework for BackboneJS with nested forms, editable lists and validation
MIT License
2.17k stars 413 forks source link

usecase for using commit({validate:false}) #359

Closed 0xgeert closed 10 years ago

0xgeert commented 10 years ago

What's the usecase for using commit({validate:false})? I.e: doing form validation, but no model validation? Why not to always use commit({validate: true}), which both does form validation as well as model validation?

background: I'm looking into extending backbone-forms with validation through backbone-validation (see #317 ), which does model validation and exposes it to the form.

Doing some quick testing, it seems I can trivially make the extension (it kind of just works out of the box), but the backbone-validation rules only kick in on model-validation, so using commit({validate:false}) would not show them.

Thinking about going down this road, I see no real practical reason not to always do commit({true}) and thus have backbone.validation rules kick in all of the time.

philfreo commented 10 years ago

The reasoning is that commit is basically a wrapper around Model#set, which according to the Backbone docs does not validate by default.

See http://backbonejs.org/#Model-validate