backbone.js - Complex validation of an enitre backbone model -
i utilize backbone's plugin backbone.validation model fields validations. great declarative way of validation, plugin introduces. i'm missing, way of validating not particular field, whole model. here i'd have:
var somemodel = backbone.model.extend({ validation: { field1: { required: true }, field2: { required: true }, field3: { required: true } 'whole model': function () { // method makes complex validation logic , expected // called each time validation of model (some fields) performed } } });
i can easy when not using backbone.validation plugin, how can same when i'm using it?
you can that, see here: https://github.com/thedersen/backbone.validation#validate
"you can phone call manually without parameters validate entire model."
the plugin overwrites backbone.model.prototype.validate behind scenes. if declared rules , phone call modelinstance.validate()
should validate properties.
validation backbone.js
No comments:
Post a Comment