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

Doesn't validate belongsTo async relation #7

Closed
sescobb27 opened this issue Jun 12, 2015 · 4 comments
Closed

Doesn't validate belongsTo async relation #7

sescobb27 opened this issue Jun 12, 2015 · 4 comments

Comments

@sescobb27
Copy link

I have the following model

import DS from 'ember-data';
import Validator from '../mixins/model-validator';

var attr = DS.attr;

export default DS.Model.extend(Validator, {
  plan: DS.belongsTo('plan', {async: true}),
  validations: {
    plan: {
      presence: {
        message: 'Please select a plan'
      }
    }
  }
});

Then when I'm trying to validate a model trying to test the behavior when the validation fail, the validation pass, but if I delete the {async: true} the validations doesn't pass (as expected)

@esbanarango
Copy link
Owner

@sescobb27 Right now async relations aren't supported to be validated. One thing you could try, is resolving that promise before calling .validate().

@esbanarango
Copy link
Owner

@sescobb27 did it work resolving the promise before validating?

@sescobb27
Copy link
Author

not yet, I just remove the {async: true} to make it work, the object isn't that big to make it async

@esbanarango
Copy link
Owner

@sescobb27 belongsTo async relations are now supported!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants