Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Company ID

Generate and validate business identifiers (VAT numbers, EINs, CIFs) for 250 countries. Specific checksum implementations for GB, DE, FR, IT, and ES.

Generate

Rust

#![allow(unused)]
fn main() {
use rand::thread_rng;
use idsmith::company_id::GenOptions;

let mut rng = thread_rng();
let registry = idsmith::company_ids();

// Random country
let result = registry.generate(&GenOptions::default(), &mut rng).unwrap();

// Specific country
let opts = GenOptions { country: Some("GB".to_string()) };
let gb = registry.generate(&opts, &mut rng).unwrap();
// gb.country_code → "GB"
// gb.name         → "VAT Number"
// gb.code         → "GB123456789"
}

Python

import idsmith

result = idsmith.CompanyId.generate()                   # random country
gb = idsmith.CompanyId.generate(country="GB")           # specific country
print(gb["name"])  # VAT Number
print(gb["code"])  # GB123456789

JavaScript

const { CompanyId } = require('idsmith');

const result = CompanyId.generate();      // random country
const gb = CompanyId.generate('GB');      // specific country
console.log(gb.name);  // VAT Number
console.log(gb.code);  // GB123456789

Validate

Rust

#![allow(unused)]
fn main() {
idsmith::company_ids().validate("GB", "GB123456789");  // true
idsmith::company_ids().validate("DE", "DE141158922");  // true
}

Python

idsmith.CompanyId.validate("GB", "GB123456789")  # True

JavaScript

CompanyId.validate('GB', 'GB123456789');  // true

Checksum-Verified Countries

CountryFormatChecksum
GBVAT Number (9 digits)Weighted mod-97
DEUSt-IdNr (9 digits)ISO 7064 mod 11,10
FRTVA (11 digits)SIREN + mod-97
ITPartita IVA (11 digits)Luhn
ESCIF (letter + 7 digits + check)Custom weighted