learning_basics_backbone icon indicating copy to clipboard operation
learning_basics_backbone copied to clipboard

Error in chapter 4 - validate doesn't work

Open paulyang0125 opened this issue 11 years ago • 1 comments

there's no "false" returned or error in the console unless you put {validate: true} on set func....

like

person.set('age', -1, {validate: true}); Age must be positive false

Grabbed from http://www.codebeerstartups.com/2012/12/4-adding-validations-in-models-in-backbone-js-learning-backbone-js/

var person = new Person; person.get('age')// will return 23 as default value person.set('age', -1)// will return false and value ie -1 will not be set

person.on('error', function(model,error){ console.log(error); // printing the error message on console. });

paulyang0125 avatar Oct 13 '14 08:10 paulyang0125

Yeah, just to confirm I'm still getting the same as above.

Also in the post like 9 is written if ( attributes.age < ){ instead of if ( attributes.age < 0){

Though i realise this is an old tut now, not sure if it's still maintained?

huwd avatar Mar 13 '16 18:03 huwd