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

Presence validation on belongsTo relationship stopped working on 3.11. #651

Open
alejandrodevs opened this issue Aug 8, 2019 · 6 comments

Comments

@alejandrodevs
Copy link

alejandrodevs commented Aug 8, 2019

Environment

  • Ember Version: 3.11.1
  • Ember CLI Version: 3.11.0
  • Ember CP Validations Version: 4.0.0-beta.9

Steps to Reproduce

After I upgraded from ember 3.10 to 3.11 the presence validations on belongsTo relationships stopped working. Looks like it does not detect that the associated record has changed and displays This field can't be blank even when record is well assigned.

After I ran notifyPropertyChange on that property the validations get updated and works correctly.

This is how my model looks like:

import attr from 'ember-data/attr';
import Model from 'ember-data/model';
import { belongsTo } from 'ember-data/relationships';
import { buildValidations, validator } from 'ember-cp-validations';

const Validations = buildValidations({
  title: [
    validator('presence', true)
  ],
  author: [
    validator('presence', true)
  ]
});

export default Model.extend(Validations, {
  title:  attr('string'),

  author: belongsTo()
});
@alejandrodevs
Copy link
Author

alejandrodevs commented Aug 8, 2019

Adding debounce value makes it work:

export default buildValidations({
  title: [
    validator('presence', true)
  ],
  author: [
    validator('presence', {
      presence: true,
      debounce: 10
    })
  ]
});

This is working but it is not the best approach.
Any thoughts?

@fran-worley
Copy link

I can confirm that this is still an issue in Ember 3.12:

  • Ember Version: 3.12.0
  • Ember CLI Version: 3.12.0
  • Ember CP Validations Version: 4.0.0.beta-9

erikap added a commit to rollvolet/frontend-crm that referenced this issue Aug 22, 2019
@arm1n
Copy link

arm1n commented Jan 30, 2020

I can confirm that this is an issue with Ember 3.12.x (both source and data) and I've also tried the latest beta 4.0.0.beta-10 - are there any plans to fix this issue in the near future? Thanks!

@maxwondercorn
Copy link

This is working on Ember 3.16, CP validations version 4.0.0-beta.10

@fsmanuel
Copy link
Contributor

@alejandrodevs @fran-worley @arm1n @erikap we droped support for ember versions < 3.16 in the last beta. Can someone confirm @maxwondercorn statement, that it work in ember versions >= 3.16?

@fsmanuel
Copy link
Contributor

I think it was fixed here 369f080

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

No branches or pull requests

5 participants