Multiple conditionally required fields validation
nicpalard opened this issue · comments
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 ?