-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Milestone
Description
Is your feature request related to a problem? Please describe.
No, just a useful method that I could not find in the lib.
Is there any "native" way to combine/join multiples ValidationResult's?
Describe the solution you'd like
It is very useful to combine/join mutiples ValidationResults into a new ValidationResults, for example..
ValidationResult fullValidation = new[]
{
ValidationA(obj),
ValidationB(obj),
ValidationC(obj),
}
.Combine();
ValidationResult ValidationA(Person x) { ... }
ValidationResult ValidationB(Person x) { ... }
ValidationResult ValidationC(Person x) { ... }Describe alternatives you've considered
In my current system I've added the following extension methods.
If there are interest to make them part of the library (in case of no current native solution) I can submit a PR.
public static ValidationResult Combine(this ValidationResult validationResult, params ValidationResult[] failuresResult)
{
return failuresResult.Append(validationResult).Combine();
}
public static ValidationResult Combine(this IEnumerable<ValidationResult> failuresResult)
{
var errors = failuresResult.SelectMany(x => x.Errors);
return new ValidationResult(errors);
}Additional Context
No response
cremor
Metadata
Metadata
Assignees
Labels
No labels