Microsoft.Extensions.Options.DataAnnotations
10.0.8
Prefix Reserved
See the version list below for details.
dotnet add package Microsoft.Extensions.Options.DataAnnotations --version 10.0.8
NuGet\Install-Package Microsoft.Extensions.Options.DataAnnotations -Version 10.0.8
<PackageReference Include="Microsoft.Extensions.Options.DataAnnotations" Version="10.0.8" />
<PackageVersion Include="Microsoft.Extensions.Options.DataAnnotations" Version="10.0.8" />
<PackageReference Include="Microsoft.Extensions.Options.DataAnnotations" />
paket add Microsoft.Extensions.Options.DataAnnotations --version 10.0.8
#r "nuget: Microsoft.Extensions.Options.DataAnnotations, 10.0.8"
#:package Microsoft.Extensions.Options.DataAnnotations@10.0.8
#addin nuget:?package=Microsoft.Extensions.Options.DataAnnotations&version=10.0.8
#tool nuget:?package=Microsoft.Extensions.Options.DataAnnotations&version=10.0.8
About
Microsoft.Extensions.Options.DataAnnotations is a library that adds extra validation functionality to configuration options using data annotations.
It allows to apply validation rules to configuration classes to ensure they are correctly configured before the application starts running.
This way, misconfiguration issues are catched early during the application startup rather than facing them later in production.
Key Features
- Enables validation of configuration options using data annotations.
- Early detection of misconfiguration issues during application startup.
How to Use
While configuring services, chain the ValidateDataAnnotations() and ValidateOnStart() methods to the AddOptions method for your configuration class.
Here is a simple example demonstrating how to validate options on application startup:
services
.AddOptions<MyOptions>()
.ValidateDataAnnotations()
.ValidateOnStart();
In the configuration class, use data annotations to specify the validation rules.
For instance, in the following MyOptions class, the Name property is marked as required:
using System.ComponentModel.DataAnnotations;
public class MyOptions
{
[Required(AllowEmptyStrings = false)]
public string Name { get; set; }
}
With this setup, an error indicating that the Name field is required will be thrown upon startup if it hasn't been configured.
Main Types
The main types provided by this library are:
Microsoft.Extensions.Options.DataAnnotationsValidateOptions<TOptions>Microsoft.Extensions.DependencyInjection.OptionsBuilderDataAnnotationsExtensions
Additional Documentation
Related Packages
Core options: Microsoft.Extensions.Options
Feedback & Contributing
Microsoft.Extensions.Options.DataAnnotations is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
| .NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.8)
- Microsoft.Extensions.Options (>= 10.0.8)
-
.NETStandard 2.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.8)
- Microsoft.Extensions.Options (>= 10.0.8)
- System.ComponentModel.Annotations (>= 5.0.0)
-
.NETStandard 2.1
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.8)
- Microsoft.Extensions.Options (>= 10.0.8)
- System.ComponentModel.Annotations (>= 5.0.0)
-
net10.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.8)
- Microsoft.Extensions.Options (>= 10.0.8)
-
net8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.8)
- Microsoft.Extensions.Options (>= 10.0.8)
-
net9.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.8)
- Microsoft.Extensions.Options (>= 10.0.8)
NuGet packages (1.1K)
Showing the top 5 NuGet packages that depend on Microsoft.Extensions.Options.DataAnnotations:
| Package | Downloads |
|---|---|
|
Microsoft.AspNetCore.App
Provides a default set of APIs for building an ASP.NET Core application. This package requires the ASP.NET Core runtime. This runtime is installed by the .NET Core SDK, or can be acquired separately using installers available at https://aka.ms/dotnet-download. |
|
|
Microsoft.AspNetCore.All
Provides a default set of APIs for building an ASP.NET Core application, and also includes API for third-party integrations with ASP.NET Core. This package requires the ASP.NET Core runtime. This runtime is installed by the .NET Core SDK, or can be acquired separately using installers available at https://aka.ms/dotnet-download. |
|
|
Umbraco.Cms.Infrastructure
Contains the infrastructure assembly needed to run Umbraco CMS. |
|
|
Umbraco.Cms.Examine.Lucene
Adds Examine searching support using Lucene to Umbraco CMS. |
|
|
Umbraco.Cms.Core
Contains the core assembly needed to run Umbraco CMS. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 11.0.0-preview.4.26230.115 | 278 | 5/12/2026 |
| 11.0.0-preview.3.26207.106 | 897 | 4/14/2026 |
| 11.0.0-preview.2.26159.112 | 1,305 | 3/10/2026 |
| 11.0.0-preview.1.26104.118 | 1,740 | 2/10/2026 |
| 10.0.8 | 416,366 | 5/12/2026 |
| 10.0.7 | 1,003,062 | 4/21/2026 |
| 10.0.6 | 362,835 | 4/14/2026 |
| 10.0.5 | 1,286,682 | 3/12/2026 |
| 10.0.4 | 207,410 | 3/10/2026 |
| 10.0.3 | 1,257,850 | 2/10/2026 |
| 10.0.2 | 1,590,970 | 1/13/2026 |
| 10.0.1 | 1,268,411 | 12/9/2025 |
| 10.0.0 | 1,983,072 | 11/11/2025 |
| 9.0.16 | 20,413 | 5/12/2026 |
| 9.0.15 | 87,407 | 4/14/2026 |
| 9.0.14 | 95,840 | 3/10/2026 |
| 9.0.13 | 118,940 | 2/10/2026 |
| 9.0.12 | 155,915 | 1/13/2026 |
| 9.0.11 | 877,205 | 11/11/2025 |
| 9.0.10 | 1,698,068 | 10/14/2025 |