Skip to content

Commit 387d709

Browse files
Copilotwadepickett
andauthored
Add .NET 10 validation package documentation to validation articles (#36015)
* Initial plan * Add .NET 10 validation package documentation Co-authored-by: wadepickett <[email protected]> * Add comment to validation package include file Co-authored-by: wadepickett <[email protected]> * Fix copilot instructions violations: add frontmatter to include file and update ms.date Co-authored-by: wadepickett <[email protected]> * Update aspnetcore/includes/validation-package-net10.md Removed extra space in include file. * Fix nested moniker ranges in validation articles Co-authored-by: wadepickett <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: wadepickett <[email protected]> Co-authored-by: Wade Pickett <[email protected]>
1 parent 9fb61e8 commit 387d709

File tree

4 files changed

+51
-2
lines changed

4 files changed

+51
-2
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
title: .NET 10 validation package information
3+
ai-usage: ai-assisted
4+
ms.author: wpickett
5+
ms.date: 08/28/2025
6+
---
7+
<!-- USED in validation docs for .NET 10 -->
8+
9+
## Validation in .NET 10
10+
11+
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.
12+
13+
To use the `Microsoft.Extensions.Validation` APIs:
14+
15+
* Add the following package reference:
16+
17+
```xml
18+
<PackageReference Include="Microsoft.Extensions.Validation" Version="10.0.0" />
19+
```
20+
21+
The functionality remains the same but now requires an explicit package reference.
22+
23+
* Register validation services with dependency injection:
24+
25+
```csharp
26+
builder.Services.AddValidation();
27+
```

aspnetcore/mvc/models/validation.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Learn about model validation in ASP.NET Core MVC and Razor Pages.
55
monikerRange: '>= aspnetcore-3.1'
66
ms.author: tdykstra
77
ms.custom: mvc
8-
ms.date: 05/7/2023
8+
ms.date: 08/28/2025
99
uid: mvc/models/validation
1010
---
1111
# Model validation in ASP.NET Core MVC and Razor Pages
@@ -16,6 +16,14 @@ 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:fundamentals/index#how-to-download-a-sample)).
1818

19+
:::moniker-end
20+
21+
:::moniker range=">= aspnetcore-10.0"
22+
[!INCLUDE[](~/includes/validation-package-net10.md)]
23+
:::moniker-end
24+
25+
:::moniker range=">= aspnetcore-7.0"
26+
1927
## Model state
2028

2129
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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ In this section:
2626
One of the design tenets of MVC is [DRY](https://wikipedia.org/wiki/Don%27t_repeat_yourself) ("Don't Repeat Yourself"). ASP.NET Core MVC encourages you to specify functionality or behavior only once, and then have it be reflected everywhere in an app. This reduces the amount of code you need to write and makes the code you do write less error prone, easier to test, and easier to maintain.
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.
29+
:::moniker-end
30+
31+
:::moniker range=">= aspnetcore-10.0"
32+
[!INCLUDE[](~/includes/validation-package-net10.md)]
33+
:::moniker-end
34+
35+
:::moniker range=">= aspnetcore-9.0"
2936

3037
## Delete the previously edited data
3138

aspnetcore/tutorials/razor-pages/validation.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Part 8, add validation
33
author: wadepickett
44
description: Part 8 of tutorial series on Razor Pages.
55
ms.author: wpickett
6-
ms.date: 06/23/2024
6+
ms.date: 08/28/2025
77
uid: tutorials/razor-pages/validation
88
---
99
# Part 8 of tutorial series on Razor Pages
@@ -27,6 +27,13 @@ The validation support provided by Razor Pages and Entity Framework is a good ex
2727

2828
* Validation rules are declaratively specified in one place, in the model class.
2929
* Rules are enforced everywhere in the app.
30+
:::moniker-end
31+
32+
:::moniker range=">= aspnetcore-10.0"
33+
[!INCLUDE[](~/includes/validation-package-net10.md)]
34+
:::moniker-end
35+
36+
:::moniker range=">= aspnetcore-9.0"
3037

3138
## Add validation rules to the movie model
3239

0 commit comments

Comments
 (0)