NationalIdentifiers.AspNetCore 0.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package NationalIdentifiers.AspNetCore --version 0.2.0
                    
NuGet\Install-Package NationalIdentifiers.AspNetCore -Version 0.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NationalIdentifiers.AspNetCore" Version="0.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NationalIdentifiers.AspNetCore" Version="0.2.0" />
                    
Directory.Packages.props
<PackageReference Include="NationalIdentifiers.AspNetCore" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NationalIdentifiers.AspNetCore --version 0.2.0
                    
#r "nuget: NationalIdentifiers.AspNetCore, 0.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package NationalIdentifiers.AspNetCore@0.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NationalIdentifiers.AspNetCore&version=0.2.0
                    
Install as a Cake Addin
#tool nuget:?package=NationalIdentifiers.AspNetCore&version=0.2.0
                    
Install as a Cake Tool

NationalIdentifiers.AspNetCore

ASP.NET Core integration for NationalIdentifiers.Core: validation of national tax identifiers for 195 countries in web APIs. Targets .NET 8 and .NET 10.

Setup

builder.Services.AddNationalIdentifiers();

Validation attribute

public sealed record RegisterRequest(
    string Country,
    [ValidTaxId(nameof(Country))] string TaxId);

The attribute validates the tax ID against the rules of the country named by the companion property, so a single field can hold an Italian Codice Fiscale, a Partita IVA or any foreign TIN depending on the user.

[ValidTaxId] skips null, empty and whitespace-only values, leaving required field checks to [Required] and matching the Angular validator's behavior. It also returns a structured failure message rather than throwing, which is compatible with ASP.NET Core ModelState and problem-detail payloads.

The default policy mode rejects only definitive failures. Use strict mode when every failed local check must block the request:

[ValidTaxId(nameof(Country), Mode = TaxIdValidationMode.Strict)]
public string? TaxId { get; init; }

Action filter

TaxIdValidationFilter validates incoming requests centrally and produces RFC 7807 problem details for failures.

Policy decisions

Combine with TaxIdPolicy.Evaluate from the core package to map results to accept/warn/block decisions — block on failed check digits, warn (store and flag) for countries with format-only rules instead of rejecting users.

This package now shares the same policy semantics as the JS helper taxIdCheckOutcome, making warning and blocking behavior consistent between backend and frontend validation.

License

MIT

Product Compatible and additional computed target framework versions.
.NET 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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.2 154 6/16/2026
1.0.1 124 6/16/2026
1.0.0 136 6/15/2026
0.2.0 121 6/13/2026
0.1.0 138 6/12/2026