Skip to content

Suggestion for conditional validation #134

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

Open
janhaesen opened this issue Jan 13, 2023 · 1 comment
Open

Suggestion for conditional validation #134

janhaesen opened this issue Jan 13, 2023 · 1 comment

Comments

@janhaesen
Copy link

I'm wondering how one would suggest altering the code concerning validations in such a way that a conditional validator can be incorporated that is dependent on other values.

For example given an object that has a start and end date parameter. I'd like to validate that the end date is higher or equal to the start date.

Currently all validation is on a individual field basis. Which works well for 95% of the use cases. I was personally thinking of adjusting the ValidationHandler

to create perhaps a wrapper around it that will be able to validate the properties once all others are done. Considering the ValidationHandler is recursive this is in theory already kind of the case. I've yet to found a way that I see fitting well.

What suggestions would you have?
Would you feel this being a worthy contribution to the library?

@Wicpar
Copy link
Collaborator

Wicpar commented Jan 14, 2023

In priciple the use case would be to wrap that in a new class that represents a date range and validate that.
But if you believe you can make an ergonomic alternative i will gladly accept it.

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

2 participants