Microsoft.Extensions.Options.DataAnnotations 10.0.14

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

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.

Showing the top 20 packages that depend on Microsoft.Extensions.Options.DataAnnotations.

Packages Downloads
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.
50
Bet.Extensions.Options
The collection of the functionality for Options Validations that can be utilized for AspNetCore or GenericHost.
47
Bet.Extensions.Options
The collection of the functionality for Options Validations that can be utilized for AspNetCore or GenericHost.
45
Bet.Extensions.Options
The collection of the functionality for Options Validations that can be utilized for AspNetCore or GenericHost.
44
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.
44
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.
42
Bet.Extensions.Options
The collection of the functionality for Options Validations that can be utilized for AspNetCore or GenericHost.
41
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.
40
Bet.Extensions.Options
The collection of the functionality for Options Validations that can be utilized for AspNetCore or GenericHost.
39
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.
39
Bet.Extensions.Options
Collection of Options Validations functionality for AspNetCore or GenericHost.
38
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. This package was built from the source at: https://github.com/aspnet/Universe/tree/244e037a222a7cd0a17feafb7f3a625fde40de97
37
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.
37
Bet.Extensions.Options
The collection of the functionality for Options Validations that can be utilized for AspNetCore or GenericHost.
36
Bet.Extensions.Options
The Collection of the Options Validations functionality for AspNetCore or GenericHost.
36

Version Downloads Last updated
11.0.0-rc.3.26522.148 5 10/26/2026
11.0.0-rc.2.26504.105 8 10/13/2026
11.0.0-rc.1.26425.128 16 09/10/2026
11.0.0-preview.7.26381.103 22 08/14/2026
11.0.0-preview.6.26359.118 25 07/19/2026
11.0.0-preview.5.26302.115 29 06/11/2026
11.0.0-preview.4.26230.115 39 05/13/2026
11.0.0-preview.3.26207.106 37 04/14/2026
11.0.0-preview.2.26159.112 42 03/11/2026
11.0.0-preview.1.26104.118 48 02/12/2026
10.0.14 4 10/26/2026
10.0.13 8 10/14/2026
10.0.12 13 09/10/2026
10.0.11 19 08/14/2026
10.0.10 23 07/16/2026
10.0.9 24 06/11/2026
10.0.8 42 05/12/2026
10.0.7 43 04/24/2026
10.0.6 49 04/15/2026
10.0.5 32 03/13/2026
10.0.4 45 03/11/2026
10.0.3 42 02/12/2026
10.0.2 45 01/14/2026
10.0.1 3 09/30/2026
10.0.0 50 12/15/2025
10.0.0-rc.2.25502.107 31 12/14/2025
10.0.0-rc.1.25451.107 37 12/21/2025
10.0.0-preview.7.25380.108 42 12/21/2025
10.0.0-preview.6.25358.103 45 12/22/2025
10.0.0-preview.5.25277.114 42 12/21/2025
10.0.0-preview.4.25258.110 42 12/21/2025
10.0.0-preview.3.25171.5 51 12/11/2025
10.0.0-preview.2.25163.2 44 12/11/2025
10.0.0-preview.1.25080.5 44 12/11/2025
9.0.22 3 10/26/2026
9.0.21 6 10/14/2026
9.0.20 13 09/10/2026
9.0.19 22 08/14/2026
9.0.18 20 07/16/2026
9.0.17 28 06/11/2026
9.0.16 42 05/13/2026
9.0.15 39 04/15/2026
9.0.14 43 03/11/2026
9.0.13 37 02/12/2026
9.0.12 53 01/14/2026
9.0.11 50 12/20/2025
9.0.10 39 12/20/2025
9.0.9 52 12/20/2025
9.0.8 28 12/20/2025
9.0.7 47 12/20/2025
9.0.6 52 12/20/2025
9.0.5 47 12/22/2025
9.0.4 47 12/11/2025
9.0.3 52 12/11/2025
9.0.2 58 12/11/2025
9.0.1 48 12/11/2025
9.0.0 16 10/15/2026
9.0.0-rc.2.24473.5 34 12/11/2025
9.0.0-rc.1.24431.7 29 12/11/2025
9.0.0-preview.7.24405.7 3 10/06/2026
9.0.0-preview.6.24327.7 40 12/21/2025
9.0.0-preview.5.24306.7 46 12/11/2025
9.0.0-preview.4.24266.19 52 12/11/2025
9.0.0-preview.3.24172.9 10 10/13/2026
9.0.0-preview.2.24128.5 48 12/11/2025
9.0.0-preview.1.24080.9 51 12/11/2025
8.0.0 60 12/11/2025
8.0.0-rc.2.23479.6 33 12/11/2025
8.0.0-rc.1.23419.4 7 10/01/2026
8.0.0-preview.7.23375.6 39 12/11/2025
8.0.0-preview.6.23329.7 46 12/11/2025
8.0.0-preview.5.23280.8 58 12/10/2025
8.0.0-preview.4.23259.5 50 12/11/2025
8.0.0-preview.3.23174.8 8 10/04/2026
8.0.0-preview.2.23128.3 44 12/11/2025
8.0.0-preview.1.23110.8 11 10/15/2026
7.0.0 56 12/11/2025
7.0.0-rc.2.22472.3 53 12/11/2025
7.0.0-rc.1.22426.10 52 12/11/2025
7.0.0-preview.7.22375.6 47 12/11/2025
7.0.0-preview.6.22324.4 41 12/11/2025
7.0.0-preview.5.22301.12 35 12/15/2025
7.0.0-preview.4.22229.4 29 12/11/2025
7.0.0-preview.3.22175.4 35 12/21/2025
7.0.0-preview.2.22152.2 54 12/12/2025
7.0.0-preview.1.22076.8 38 12/11/2025
6.0.2-mauipre.1.22102.15 57 01/05/2026
6.0.2-mauipre.1.22054.8 61 12/11/2025
6.0.1 34 12/20/2025
6.0.0 54 12/15/2025
6.0.0-rc.2.21480.5 9 10/17/2026
6.0.0-rc.1.21451.13 43 12/11/2025
6.0.0-preview.7.21377.19 43 12/12/2025
6.0.0-preview.6.21352.12 56 12/11/2025
6.0.0-preview.5.21301.5 45 12/11/2025
6.0.0-preview.4.21253.7 52 12/14/2025
6.0.0-preview.3.21201.4 44 12/11/2025
6.0.0-preview.2.21154.6 51 12/21/2025
6.0.0-preview.1.21102.12 35 12/11/2025
5.0.0 57 12/14/2025
5.0.0-rc.2.20475.5 30 12/15/2025
5.0.0-rc.1.20451.14 47 12/14/2025
5.0.0-preview.8.20407.11 48 12/11/2025
5.0.0-preview.7.20364.11 52 12/15/2025
5.0.0-preview.6.20305.6 44 12/11/2025
5.0.0-preview.5.20278.1 28 12/11/2025
5.0.0-preview.4.20251.6 45 12/11/2025
5.0.0-preview.3.20215.2 39 12/12/2025
5.0.0-preview.2.20160.3 32 12/11/2025
5.0.0-preview.1.20120.4 43 12/11/2025
3.1.32 46 12/11/2025
3.1.31 35 12/20/2025
3.1.30 40 12/11/2025
3.1.29 43 12/11/2025
3.1.28 32 12/11/2025
3.1.27 13 10/20/2026
3.1.26 43 12/11/2025
3.1.25 36 12/11/2025
3.1.24 58 12/11/2025
3.1.23 50 12/11/2025
3.1.22 47 12/11/2025
3.1.21 9 10/03/2026
3.1.20 11 10/01/2026
3.1.19 50 12/11/2025
3.1.18 44 12/11/2025
3.1.17 42 12/11/2025
3.1.16 47 12/11/2025
3.1.15 48 12/11/2025
3.1.14 11 10/07/2026
3.1.13 11 10/13/2026
3.1.12 46 12/12/2025
3.1.11 49 12/15/2025
3.1.10 53 12/11/2025
3.1.9 35 12/12/2025
3.1.8 58 12/11/2025
3.1.7 49 12/11/2025
3.1.6 46 12/11/2025
3.1.5 41 12/11/2025
3.1.4 38 12/20/2025
3.1.3 46 12/11/2025
3.1.2 14 09/30/2026
3.1.1 10 10/08/2026
3.1.0 61 12/20/2025
3.1.0-preview3.19553.2 45 12/15/2025
3.1.0-preview2.19525.4 48 12/11/2025
3.1.0-preview1.19506.1 50 12/11/2025
3.0.3 43 12/15/2025
3.0.2 36 12/20/2025
3.0.1 36 12/15/2025
3.0.0 55 12/20/2025
3.0.0-rc1.19456.10 44 12/11/2025
3.0.0-preview9.19423.4 39 12/11/2025
3.0.0-preview8.19405.4 41 12/11/2025
3.0.0-preview7.19362.4 41 12/11/2025
3.0.0-preview6.19304.6 33 12/11/2025
3.0.0-preview5.19227.9 37 12/11/2025
3.0.0-preview4.19216.2 45 12/11/2025
3.0.0-preview3.19153.1 44 12/11/2025
3.0.0-preview.19074.2 39 12/11/2025
3.0.0-preview.18572.1 47 12/11/2025
2.2.0 43 12/11/2025
2.2.0-preview3-35497 29 12/12/2025
2.2.0-preview2-35157 25 12/11/2025