Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing dependency to can/model #140

Closed
wants to merge 1 commit into from
Closed

missing dependency to can/model #140

wants to merge 1 commit into from

Conversation

dimaf
Copy link
Contributor

@dimaf dimaf commented Nov 2, 2012

in my case this missing dependency is causing that model instances, unless "'can/model'" explicitly stealed before validations.js, do not have validations

i see you have this comment in attibutes.js

// in some cases model might not be defined quite yet.
    if(clss === undefined){
        return;
    }

but was there a reason for not including dependency to can/model instead of that comment?

@justinbmeyer
Copy link
Contributor

validations does not depend on model, only on observe. It should be adding this functionality to Model similar to how attributes adds itself to model and observe.

@justinbmeyer
Copy link
Contributor

The following works for me

steal('can/model').then('can/observe/validations',function(){
        var Person = can.Model({
            init: function(){
                this.validate("birthday",function(birthday){
                        if(birthday > new Date){
                            return "your birthday needs to be in the past"
                        }
                    })
            }
        },{});
        var p = new Person({birthday: new Date(new Date().getTime()+1000 )});
        console.log( p.errors() );
    })

@justinbmeyer
Copy link
Contributor

ah, that was what you said should work ...

@dimaf
Copy link
Contributor Author

dimaf commented Nov 3, 2012

exactly that will work..
but from what i see in validations.js line 62
https://github.com/jupiterjs/canjs/blob/master/observe/validations/validations.js#L62

can.each([ can.Observe, can.Model ], function(clss){

it does use can.Model hence needs to have dependency to model.js right?

so I was wondering why you have not included the dependency to Model and instead added this

// in some cases model might not be defined quite yet.
    if(clss === undefined){
        return;
    }

justinbmeyer added a commit that referenced this pull request Nov 6, 2012
amcdnl added a commit that referenced this pull request Nov 6, 2012
# By Justin Meyer (2) and others
# Via Andy Kant (1) and others
* 'master' of git://github.com/jupiterjs/canjs:
  Added support in mustache for helpers with non-reference and hash arguments.
  Added test for #110 showing live bound computes
  removing a console.log
  a micro test page for #140 validations being added to model if model has already been loaded
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants