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

Multiple conditionally required fields validation

未关闭
#725 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
JavaScript
星标
439
派生
172
PR 合并指标
30 天内没有已合并 PR

描述

### Environment

- Ember Version: 3.4.4
- Ember CLI Version: 3.4.4
- Ember CP Validations Version: 4.0.0-beta.10

I have done several simple validations that are working perfectly but now I need to perform a more complex validation over 3 conditionally required fields with the following logic:

I have 3 fields that are conditionally required based on each others value:
- Field A (a belongsTo field) is optional but should be specified if field B is empty
- Field B (a belongsTo field) is also optional but should be specified alongside field C if field A is empty
- Field C (a string attribute) is optional but should be specified when field B is specified.

In other words one should specify A or (B and C).
Also: A and B and C is not valid

I can not seem to find any example for my use case. I have read about custom validators but I can't seem to make it work for that particular logic.
With custom validation I can partially achieve what I want to but how can I trigger the others field to be validated when a specific field changes ?

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。