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

Allowing child validations to be specified with on or excludes

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

描述

We have a situation where we have a model with multiple has-many child relations we would like to validate on, but on specific pages, exclude a some of the child has-many validations.

The use case is, we are creating this parent model and all of the related child models through several pages in a wizard process. On the last page everything should be valid including the children, but as they are adding or editing specific parts on each part of the wizard, only the elements related to that specific page should be validated.

It would be great to be able in the validate options for excludes or on, to be able to specify which has-many or belongs-to validates you want to exclude. For example, if you could pass something into the excludes to ignore children.

```
Parent model: Load
Load has many: Operations
Operation has many: Items
Item has validations for quantity, name, allowed

load.validate({ excludes: ['operations.items.quantity', 'operations.items.allowed'] })
```

or even better to use ember shortcuts

```
load.validate({ excludes: ['operations.items.{quantity,allowed}'] })
```

In these examples above, maybe the name is created in the first page of the wizard, but quantity isn't assigned until other parts of the wizard are completed (because other data points are needed on the following steps). It would be great if you could specify on the parent model which child validations to skip.

This can kind of be worked around today by having a property on load that the children check, or specifically setting a property on the children before validating that disables the child validation, but it would be great if you could specify everything at the parent validation call.

Any thoughts on adding such a feature?

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

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

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