-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
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
this.RuleFor(o => o).Custom(CustomValidationMethod)
.DependentRules(() =>
{
this.RuleFor(~~~~~~~~);
});
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