adopted-ember-addons / adopted-ember-addons/ember-cp-validations

Validations including a has-many relationship broken when lazily evaluated

未關閉
#686 0 則留言 2 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
JavaScript
星號
439
分支
172
PR 合併指標
30 天內沒有已合併 PR

描述

### Environment

- Ember Version: 3.16
- Ember CLI Version: 3.16?
- Ember CP Validations Version: 4

### Steps to Reproduce
outerClass:
```
buildValidations({
innerClasses: [
validator('has-many'),
validator('inline', {
dependentKeys: ['model.innerClasses.@each.foo'],
validate(value) { ... }
}],
});
```

innerClass:
```
buildValidations({
foo: validator('presence', { presence: true }),
bar: validator('presence', { presence: true }),
});
```

1. While running the app, cause both the `inline` and `has-many` validations to fail.
2. Fix the problem with `innerClass` so all its validations pass, but _don't_ fix the `inline` validation

## Expected results
Validations fail. `outerClass.validations.errors` should include 1 error with `type === 'inline'` and `attribute === 'innerClasses'`

## Actual results
Validations pass

## Workarounds
Any one of:
* Pass `{ lazy: false }` to outerClass's `buildValidations` call.
* Reorder the array passed to outerClass's `buildValidations` call so the `has-many` validation is last

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。