Presence validation on belongsTo relationship stopped working on 3.11.
alejandrodevs opened this issue · comments
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()
});
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?
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
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!
This is working on Ember 3.16, CP validations version 4.0.0-beta.10
@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
?
I think it was fixed here 369f080