Skip to content

Commit 460307b

Browse files
Copilotwadepickett
andcommitted
Add .NET 10 validation package documentation
Co-authored-by: wadepickett <[email protected]>
1 parent 6faac35 commit 460307b

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## Validation in .NET 10
2+
3+
In .NET 10, the unified validation APIs have been moved to the `Microsoft.Extensions.Validation` NuGet package. This change makes the validation APIs available outside of ASP.NET Core HTTP scenarios.
4+
5+
To use the `Microsoft.Extensions.Validation` APIs:
6+
7+
* Add the following package reference:
8+
9+
```xml
10+
<PackageReference Include="Microsoft.Extensions.Validation" Version="10.0.0" />
11+
```
12+
13+
The functionality remains the same but now requires an explicit package reference.
14+
15+
* Register validation services with dependency injection:
16+
17+
```csharp
18+
builder.Services.AddValidation();
19+
```

aspnetcore/mvc/models/validation.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ This article explains how to validate user input in an ASP.NET Core MVC or Razor
1616

1717
[View or download sample code](https://github.com/dotnet/AspNetCore.Docs/tree/main/aspnetcore/mvc/models/validation/samples) ([how to download](xref:index#how-to-download-a-sample)).
1818

19+
:::moniker range=">= aspnetcore-10.0"
20+
[!INCLUDE[](~/includes/validation-package-net10.md)]
21+
:::moniker-end
22+
1923
## Model state
2024

2125
Model state represents errors that come from two subsystems: model binding and model validation. Errors that originate from [model binding](xref:mvc/models/model-binding) are generally data conversion errors. For example, an "x" is entered in an integer field. Model validation occurs after model binding and reports errors where data doesn't conform to business rules. For example, a 0 is entered in a field that expects a rating between 1 and 5.

aspnetcore/tutorials/first-mvc-app/validation.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ One of the design tenets of MVC is [DRY](https://wikipedia.org/wiki/Don%27t_repe
2727

2828
The validation support provided by MVC and Entity Framework Core is a good example of the DRY principle in action. You can declaratively specify validation rules in one place (in the model class) and the rules are enforced everywhere in the app.
2929

30+
:::moniker range=">= aspnetcore-10.0"
31+
[!INCLUDE[](~/includes/validation-package-net10.md)]
32+
:::moniker-end
33+
3034
## Delete the previously edited data
3135

3236
In the next step, validation rules are added that don't allow null values.

aspnetcore/tutorials/razor-pages/validation.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ The validation support provided by Razor Pages and Entity Framework is a good ex
2828
* Validation rules are declaratively specified in one place, in the model class.
2929
* Rules are enforced everywhere in the app.
3030

31+
:::moniker range=">= aspnetcore-10.0"
32+
[!INCLUDE[](~/includes/validation-package-net10.md)]
33+
:::moniker-end
34+
3135
## Add validation rules to the movie model
3236

3337
The <xref:System.ComponentModel.DataAnnotations> namespace provides:

0 commit comments

Comments
 (0)