NIF
Portugal
Portuguese taxpayer number (NIF) — 9 digits with an official check digit.
Validation Generation
Open source · MIT · .NET 10
A modern .NET library for validating, generating and verifying document numbers across multiple countries using a clean and intuitive API.
14 document types · 13 generators · 4 countries
using DocumentNumber.Portugal.Vat.Validator;
var validator = new VatValidator();
if (validator.Validate("798945320"))
{
Console.WriteLine("Valid");
}
Everything you need to trust a document number before you store it.
Validators and generators for Portugal, Spain, France, Brazil, IBAN and major payment card schemes.
One call returns a clear result — format rules and check digits are handled for you.
Produce structurally valid sample numbers for tests and demos — including check digits.
Pure managed libraries built on .NET Standard — drop them into any modern .NET application.
A consistent Validate(value) and GenerateDocumentNumber() shape across every package.
MIT licensed and developed in the open on GitHub — no hidden code, no vendor lock-in.
Program against the shared IDocumentNumberValidator abstraction and swap document types freely.
Versioned on NuGet, covered by test suites and ready for real workloads.
Generated from the library catalogue — every card links to a live validator and, where available, a generator with runnable examples.
Portugal
Portuguese taxpayer number (NIF) — 9 digits with an official check digit.
Validation Generation
Portugal
Portuguese social security number (NISS) — 11 digits with embedded check digits.
Validation Generation
Portugal
Portuguese Citizen Card document number — 12 characters, digits plus a 3-letter series.
Validation Generation
Portugal
Portuguese bank account number (NIB) — 21 digits with bank check digits.
Validation Validation only
International
International Bank Account Number — mod-97 checksum per ISO 13616.
Validation Generation
Spain
Spanish tax identifiers — DNI, NIE and CIF with their official check digits.
Validation Generation
France
French VAT number (TVA) — SIREN-based with the official key check.
Validation Generation
Brazil
Brazilian taxpayer identifiers — CPF (11 digits) and CNPJ (14 digits).
Validation Generation
International
American Express card numbers — 15 digits, 34/37 prefixes, Luhn check.
Validation Generation
International
Maestro debit card numbers — 12 to 19 digits with Luhn check.
Validation Generation
International
Maestro UK debit card numbers — 12 to 19 digits with Luhn check.
Validation Generation
International
Mastercard numbers — 16 digits, 51–55 and 2221–2720 ranges, Luhn check.
Validation Generation
International
Visa card numbers — 13, 16 or 19 digits starting with 4, Luhn check.
Validation Generation
International
Visa Electron numbers — specific issuer ranges, 13 or 16 digits, Luhn check.
Validation Generation
Real, copyable snippets — exactly what you write in your application.
using DocumentNumber.Portugal.Vat.Validator;
var validator = new VatValidator();
var isValid = validator.Validate("798945320");
Console.WriteLine(isValid ? "Valid" : "Invalid");
using DocumentNumber.Portugal.Vat.Generator;
var generator = new VatGenerator();
var nif = generator.GenerateDocumentNumber();
Console.WriteLine(nif);
using DocumentNumber.Portugal.Vat.Generator;
var generator = new VatGenerator();
var samples = Enumerable.Range(0, 5)
.Select(_ => generator.GenerateDocumentNumber())
.Distinct()
.ToArray();
Console.WriteLine($"{samples.Length} sample NIFs generated");
using DocumentNumber.ValidatorAbstractions;
using DocumentNumber.Portugal.Vat.Validator;
IDocumentNumberValidator validator = new VatValidator();
var result = validator.Validate("798945320");
Console.WriteLine(result);
The same validation and generation power your .NET app gets — right here in the browser. No sign-up, nothing stored.
Small, focused packages that share one predictable design.
Every validator applies the official format and check-digit rules for its document.
Random, valid samples on demand — ideal for test data, fixtures and demos.
Small packages built on shared abstractions — take only what you need.
Rules maintained per country for Portugal, Spain, France and Brazil.
Weighted, mod-97 and Luhn check-digit algorithms implemented to specification.
One dotnet add package command and a single method call — that's it.
Install the package you need and validate your first document number in minutes.
dotnet add package DocumentNumber.Portugal.Vat.Validator
dotnet add package DocumentNumber.Portugal.Niss.Validator
dotnet add package DocumentNumber.InternationalBankAccountNumber.Validator
Every document type ships as its own package — browse them all on NuGet.
using DocumentNumber.Portugal.Vat.Validator;
var validator = new VatValidator();
var isValid = validator.Validate("798945320");
Console.WriteLine(isValid ? "Valid" : "Invalid");
Document Number Validator is an open-source effort. New countries, new document types and better algorithms all start with a pull request.
Open Source MIT License Pull Requests Welcome
View on GitHub