Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple conditionally required fields validation #725

Open
nicpalard opened this issue Sep 22, 2022 · 0 comments
Open

Multiple conditionally required fields validation #725

nicpalard opened this issue Sep 22, 2022 · 0 comments

Comments

@nicpalard
Copy link

nicpalard commented Sep 22, 2022

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant