1

I have a backbone model

var MyModel= Backbone.Model.extend({
   validation: function () 
      var validate= { 
           name: {
               required: true,
           },
      };

      return validate;

   },
});

I use sinon, mocha and chai for test. When I call model.validate() in the test it tells me that the function does not exist, how can I check that the validation works?

Emile Bergeron
  • 17,074
  • 5
  • 83
  • 129
FaDev
  • 11
  • 4

1 Answers1

1

It seems you should do the following for validation plugin to work:

_.extend(Backbone.Model.prototype, Backbone.Validation.mixin);
T J
  • 42,762
  • 13
  • 83
  • 138