-
-
Notifications
You must be signed in to change notification settings - Fork 253
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
Adding requiredWith and requiredWithout conditional rules #267
Adding requiredWith and requiredWithout conditional rules #267
Conversation
I just had a thought, I think it makes sense to force an array for the parameter set of fields we're conditionally requiring against and then use the third parameter in the rule as a boolean (strict mode, like other rules do already) which in the case of |
I just pushed another commit to implement those additional strict rules for each, now you can do the following:
I updated the tests and docs to include the strict versions. I suppose they could theoretically be their own separate rules Thanks! |
bump? |
I would love to remove similar rules that I've wrote for my project and use these instead. Any plan on merge? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this feature. Looks good.
I could have sworn I already merged this, sorry for the delay and thanks for your work! |
Hey there,
I ran into a condition a few weeks back where I needed to validate that I had either one item or two other items present in my data set and I ended up running validation twice on two different rule sets. These required rules I've added accomplish the same thing I was looking to do, where you can conditionally required fields based on whether or not other fields are present or not present in the data set and now it can be done in a single rule set! I added these new conditionals to the docs and there should be unit tests to cover each case, but please let me know if I missed anything or you have any comments.
Thanks,
Tom