You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allows recursive validation of sub-objects in a class when using [DataAnnotations validation](https://docs.microsoft.com/en-us/aspnet/core/mvc/models/validation?view=aspnetcore-3.1) (also known as Attribute Validation). The current version of .NET Core's attribute validation does not handle objects within objects (or collections of objects). Therefore it is necessary to add some glue code to recurse through the object graph.
Usage of the recursive validation is nearly identical to using the standard validator.
18
+
19
+
var validator = new RecursiveDataAnnotationValidator();
20
+
var validationResults = new List<ValidationResult>();
21
+
var result = validator.TryValidateObjectRecursive(sut, validationResults);
22
+
23
+
There are more examples in the [example](https://github.com/tgharold/RecursiveDataAnnotationsValidation/tree/master/examples) and [test](https://github.com/tgharold/RecursiveDataAnnotationsValidation/tree/master/test) projects.
24
+
25
+
### SkipRecursiveValidationAttribute
26
+
27
+
The [`[SkipRecursiveValidation]`](https://github.com/tgharold/RecursiveDataAnnotationsValidation/blob/master/src/RecursiveDataAnnotationsValidation/Attributes/SkipRecursiveValidation.cs) attribute can be used on properties where you do not want to recursively validate. An example of this can be seen in [SkippedChildrenExample.cs](https://github.com/tgharold/RecursiveDataAnnotationsValidation/blob/master/test/RecursiveDataAnnotationsValidation.Tests/TestModels/SkippedChildrenExample.cs).
0 commit comments