NationalIdentifiers.Core 0.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package NationalIdentifiers.Core --version 0.2.0
                    
NuGet\Install-Package NationalIdentifiers.Core -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.Core" Version="0.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NationalIdentifiers.Core" Version="0.2.0" />
                    
Directory.Packages.props
<PackageReference Include="NationalIdentifiers.Core" />
                    
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.Core --version 0.2.0
                    
#r "nuget: NationalIdentifiers.Core, 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.Core@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.Core&version=0.2.0
                    
Install as a Cake Addin
#tool nuget:?package=NationalIdentifiers.Core&version=0.2.0
                    
Install as a Cake Tool

NationalIdentifiers.Core

Validation of national tax identifiers for 195 countries — every commonly recognised state (193 UN members, Palestine, Vatican City). Pure .NET, no dependencies, targets .NET 8 and .NET 10.

using NationalIdentifiers.Core;

var result = TaxIdValidator.Validate("IT", "RSSMRA85T10A562S");
// result.IsValid          → true
// result.NormalizedValue  → "RSSMRA85T10A562S"
// result.ValidationLevel  → ValidationLevel.Checksum

TaxIdValidator.Validate("IT", "00743110157");  // Partita IVA: also valid
TaxIdValidator.Validate("BR", "111.444.777-35"); // CPF: normalized and checked

What you get

  • 60 countries with check-digit validation — Italy (Codice Fiscale and Partita IVA), Spain, France, Germany, Brazil, Argentina, China, Japan, South Africa and more. A failed checksum means the value is definitively wrong.
  • Format/structure validation for the rest — length and pattern rules from institutional sources (OECD AEOI, national tax authorities).
  • Explicit confidence levels — every successful result carries ValidationLevel.Checksum or ValidationLevel.Format, so you always know how strong the check was.
  • Graceful handling of edge cases — countries without a personal TIN (UAE, Qatar, Kuwait…) return NotApplicable instead of failing; unknown country codes return UnsupportedCountry instead of throwing.
  • Optional identity consistency for 37 countries — compares encoded birth date, gender or administrative place codes and, for Italy, name fragments. This remains a local consistency check, not identity verification.

Confidence semantics

The core package reports validation level explicitly. Use ValidationLevel.Checksum when a public check-digit algorithm is available and has passed, or ValidationLevel.Format when only structure/date rules are enforced. This distinction is useful for downstream decision logic and aligns with the JS package's taxIdCheckOutcome policy helper.

This release also aligns the .NET policy semantics with the JS/TS registry-driven validation model, so TaxIdPolicy.Evaluate and taxIdCheckOutcome now make consistent accept/warn/block decisions across runtimes.

Policy is evaluated per identifier family where a country mixes validation levels. Historical 9-digit Czech and Slovak birth numbers, Indonesian NIK values, Peruvian 8-digit DNI values without a check digit and Singapore M FIN values remain format-only and therefore produce Warn for non-empty format failures; their checksum-backed variants produce Block.

Registration policy helper

For sign-up flows where one field may hold a domestic tax code, a VAT number or a foreign TIN:

var outcome = TaxIdPolicy.Evaluate(TaxIdValidator.Validate(country, input));

switch (outcome)
{
    case TaxIdCheckOutcome.Accept: // passed every available check
    case TaxIdCheckOutcome.Block:  // definitively wrong (bad check digit) — reject
    case TaxIdCheckOutcome.Warn:   // cannot verify with confidence — store and flag
}

Validation pipeline

  1. Normalize (strip spaces and dashes, uppercase)
  2. Empty check
  3. Length check
  4. Format/pattern check
  5. Check-digit verification (when a public algorithm exists)

Local validation confirms the value is well-formed, not that it was actually issued to someone. For registry-level verification use official services (e.g. VIES for EU VAT numbers).

  • NationalIdentifiers.AspNetCore — DI extensions, validation attribute and action filter for ASP.NET Core.
  • tax-id on npm — the same rules for TypeScript/JavaScript, with an Angular adapter.

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.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on NationalIdentifiers.Core:

Package Downloads
NationalIdentifiers.AspNetCore

ASP.NET Core integration for policy-aware local pre-validation of national identifiers in web APIs.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.2 173 6/16/2026
1.0.1 140 6/16/2026
1.0.0 141 6/15/2026
0.2.0 136 6/13/2026
0.1.0 153 6/12/2026