Open source · MIT · .NET 10

Validate and Generate
Document Numbers in .NET

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

Program.cs
using DocumentNumber.Portugal.Vat.Validator;

var validator = new VatValidator();

if (validator.Validate("798945320"))
{
    Console.WriteLine("Valid");
}

Built for .NET developers

Everything you need to trust a document number before you store it.

Multiple document types

Validators and generators for Portugal, Spain, France, Brazil, IBAN and major payment card schemes.

Document validation

One call returns a clear result — format rules and check digits are handled for you.

Document generation

Produce structurally valid sample numbers for tests and demos — including check digits.

.NET Native

Pure managed libraries built on .NET Standard — drop them into any modern .NET application.

Clean API

A consistent Validate(value) and GenerateDocumentNumber() shape across every package.

Open Source

MIT licensed and developed in the open on GitHub — no hidden code, no vendor lock-in.

Extensible architecture

Program against the shared IDocumentNumberValidator abstraction and swap document types freely.

Production ready

Versioned on NuGet, covered by test suites and ready for real workloads.

Supported document types

Generated from the library catalogue — every card links to a live validator and, where available, a generator with runnable examples.

Portugal

NIB

Portugal

Portuguese bank account number (NIB) — 21 digits with bank check digits.

Validation Validation only

International

Spain

France

Brazil

Payment cards

Code examples

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");

Try it yourself

The same validation and generation power your .NET app gets — right here in the browser. No sign-up, nothing stored.

Example: 798945320 — demo input is never stored.

Library features

Small, focused packages that share one predictable design.

Validation Engine

Every validator applies the official format and check-digit rules for its document.

Number Generators

Random, valid samples on demand — ideal for test data, fixtures and demos.

Extensible Architecture

Small packages built on shared abstractions — take only what you need.

Country Specific Rules

Rules maintained per country for Portugal, Spain, France and Brazil.

High Quality Algorithms

Weighted, mod-97 and Luhn check-digit algorithms implemented to specification.

Easy Integration

One dotnet add package command and a single method call — that's it.

Get started

Install the package you need and validate your first document number in minutes.

1. Install

bash
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.

2. Validate

Program.cs
using DocumentNumber.Portugal.Vat.Validator;

var validator = new VatValidator();
var isValid = validator.Validate("798945320");

Console.WriteLine(isValid ? "Valid" : "Invalid");

Contributing

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