Microsoft.Extensions.Options.DataAnnotations 9.0.23

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.
62
Bet.Extensions.Options
The collection of the functionality for Options Validations that can be utilized for AspNetCore or GenericHost.
53
Bet.Extensions.Options
The collection of the functionality for Options Validations that can be utilized for AspNetCore or GenericHost.
52
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.
52
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.
51
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
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
49
Bet.Extensions.Options
The Collection of the Options Validations functionality for AspNetCore or GenericHost.
48
Bet.Extensions.Options
The collection of the functionality for Options Validations that can be utilized for AspNetCore or GenericHost.
48
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.
48
Bet.Extensions.Options
Collection of Options Validations functionality for AspNetCore or GenericHost.
47
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
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.
45
Bet.Extensions.Options
The collection of the functionality for Options Validations that can be utilized for AspNetCore or GenericHost.
43
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.
43
Bet.Extensions.Options
The Collection of the Options Validations functionality for AspNetCore or GenericHost.
42
Bet.Extensions.Options
The collection of the functionality for Options Validations that can be utilized for AspNetCore or GenericHost.
42

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