Skip to content

Commit d09a1ec

Browse files
committed
Create README file for 'dotnet pack'
1 parent efa425b commit d09a1ec

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# RecursiveDataAnnotationsValidation
2+
3+
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.
4+
5+
## Installation
6+
7+
### .NET Core
8+
9+
$ dotnet add package RecursiveDataAnnotationsValidation
10+
11+
### Package Manager
12+
13+
PM> Install-Package RecursiveDataAnnotationsValidation
14+
15+
## Usage
16+
17+
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).

src/RecursiveDataAnnotationsValidation/RecursiveDataAnnotationsValidation.csproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1414
<RepositoryUrl>https://github.com/tgharold/RecursiveDataAnnotationsValidation</RepositoryUrl>
1515
<PackageTags>dataannotation validation validator</PackageTags>
16-
<PackageReadmeFile>../README.md</PackageReadmeFile>
16+
<PackageReadmeFile>README.md</PackageReadmeFile>
1717
</PropertyGroup>
1818

1919
<PropertyGroup>
@@ -25,4 +25,8 @@
2525
<PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" />
2626
</ItemGroup>
2727

28+
<ItemGroup>
29+
<None Include="README.md" Pack="true" PackagePath="\" />
30+
</ItemGroup>
31+
2832
</Project>

0 commit comments

Comments
 (0)