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
DependentRules when using .Custom() validation #2170
Comments
Currently 'resolved' the issue by abusing the RootContextData. I add a key/value to it whenever i call 'AddFailure'. It would've been nice if we could just access the Failures property of the context.
|
Thanks for the suggestion - we can look at that in the future. For now, you can achieve the same result by using |
|
I had to revert this as it requires a breaking change, so isn't something that can be implemented in 11.x. Will re-target for 12.0 instead. |
Implemented in #2177, for 12.0 |
Is your feature request related to a problem? Please describe.
I'm using Custom validation to compare a few sets of timeranges and want to return a detailed error message to the user so he knows which timeranges are causing problems. As the timeranges are based on calculations it's not ideal to split these up into seperate validators because then the calculations would need to be repeated every time. Hence the custom validation with .addFailure() messages works best.
Only if those validations succeed, do I want to continue checking a set of other rules. Checking these rules if the previous set fails would only cause confusion in the error list. For this this library has the .DependentRules option, but this option is not available when calling a .Custom() validation.
Describe the solution you'd like
Describe alternatives you've considered
Also found documentation on using the When() syntax, but can't seem to get this to work either. I suppose I could add the dependentrules check at the end of the custom validator, but that would result into less readable code.
Additional Context
No response
The text was updated successfully, but these errors were encountered: