Skip to content

Repository files navigation

docs-code

GoDocGo CoverageLicenseGo Report Card

Go library for validation and generation of Russian official document codes.

Note: The API is not yet stable and may change in future versions.

Supported Document Codes

CodeDescriptionValidateGenerate
BIKBank Identification Code (БИК)++
INNTaxpayer Identification Number (ИНН)++
KPPTax Registration Reason Code (КПП)++
OGRNPrimary State Registration Number (ОГРН)++
OGRNIPPrimary State Registration Number for IE (ОГРНИП)++
SNILSInsurance Individual Account Number (СНИЛС)++
OKATORussian Classification of Administrative Territories-

¹ OKATO validation checks the format and level ranges only; existence lookup and generation are not implemented yet and return okato.ErrNotImplemented. OKATO is not part of the top-level Validate/Generate dispatch — use the okato package directly.

Requirements

  • Go 1.25+

Installation

go get github.com/sshaplygin/docs-code

Usage

Validate a document code

import (
"log"
docs_code "github.com/sshaplygin/docs-code"
)
isValid, err:=docs_code.Validate(docs_code.INN, "526317984689")
iferr!=nil {
log.Fatal(err)
}
if!isValid {
log.Println("INN is invalid")
} else {
log.Println("INN is valid")
}

Generate a document code

import (
"fmt""log"
docs_code "github.com/sshaplygin/docs-code"
)
code, err:=docs_code.Generate(docs_code.INN)
iferr!=nil {
log.Fatal(err)
}
fmt.Println("Generated INN:", code)

Use a specific package directly

Each document type also exposes its own package with additional functions:

import"github.com/sshaplygin/docs-code/inn"// Generate specific INN typeslegalINN:=inn.GenerateLegal()
physicalINN:=inn.GeneratePhysical()
// Validateok, err:=inn.Validate("526317984689")

Benchmarks

See BENCHMARKS.md for performance data.

Project Structure

docs-code/
├── bik/ # BIK validation and generation
├── inn/ # INN validation and generation
├── kpp/ # KPP validation and generation
├── ogrn/ # OGRN validation and generation
├── ogrnip/ # OGRNIP validation and generation
├── okato/ # OKATO (in progress)
├── snils/ # SNILS validation and generation
├── fts/ # Federal Tax Service data (regions, departments)
├── models/ # Shared error types
├── utils/ # Internal helpers
└── parser/ # Data parsers (BIK, OKATO, subjects)

References

License

MIT

Releases

Packages

Used by

Contributors

Languages