lcoq / ember-validations

Ember-Validations - An Ember.js library for handling object validations
MIT License
122 stars 25 forks source link

Uncaught TypeError: Object [object Object] has no method 'validate' #33

Open sydekumf opened 10 years ago

sydekumf commented 10 years ago

Unfortunately I couldn't create a working example with your tutorial because Ember.Object.extend does not work, is it outdated?

So I have the following:

App.User = DS.Model.extend(Ember.Validations, {
    validations: {
        firstname: {
            presence: true
        }
   }
}

My Controller which handles the user object which is created by user input (form elements):

App.IndexController = Ember.Controller.extend({
    actions: {
        register: function(){
            var user = this.get('model');
            user.validate();
       }
    }
});

At that moment I get the error: Uncaught TypeError: Object [object Object] has no method 'validate' What have I done wrong? Bug? Thx for help.

For your information, why Ember.Object.extend does not work, I get the following error then:

Assertion failed: Expected hash or Mixin instance, got [object Undefined] ember.js:394
DEPRECATION: Action handlers contained in an `events` object are deprecated in favor of putting them in an `actions` object (error on <App.ApplicationRoute:ember230>)
        at Object.triggerEvent (http://localhost:9000/bower_components/ember/ember.js:30519:13)
        at trigger (http://localhost:9000/bower_components/ember/ember.js:29641:16)
        at handleError (http://localhost:9000/bower_components/ember/ember.js:29903:9)
        at invokeCallback (http://localhost:9000/bower_components/ember/ember.js:8055:19)
        at null.<anonymous> (http://localhost:9000/bower_components/ember/ember.js:8109:11)
        at EventTarget.trigger (http://localhost:9000/bower_components/ember/ember.js:7878:22)
        at http://localhost:9000/bower_components/ember/ember.js:8180:17
        at Object.DeferredActionQueues.flush (http://localhost:9000/bower_components/ember/ember.js:5459:24)
        at Object.Backburner.end (http://localhost:9000/bower_components/ember/ember.js:5545:27) 
lcoq commented 10 years ago

You are using Ember data, and I'm not sure this library works with the latests versions. I've sadly no time to work on it now, so feel free to submit a PR if you want to go deeper.

You can also take a look at dockyard/ember-validations which is pretty cool, and the project owner seems to have more time to work on it than me :(