GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Why Go
  • Case Studies
  • Use Cases
  • Security
  • Learn
  • Effective Go
  • Go User Manual
  • Standard library
  • Release Notes
  • API
  • Packages
  • Recorded Talks
  • Meetups
  • Conferences

This view

  • Original page
  • New address

GeezerVison is showing pkg.go.dev — docs_code package - github.com/sshaplygin/docs-code - Go Packages

Details

  • checked Valid go.mod file

    The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.

  • checked Redistributable license

    Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.

  • checked Tagged version

    Modules with tagged versions give importers more predictable builds.

  • unchecked Stable version

    When a project reaches major version v1 it is considered stable.

  • Learn more about best practices

Repository

github.com/sshaplygin/docs-code

Links

  • Open Source Insights Logo Open Source Insights

README ¶

docs-code

GoDoc Go Coverage License Go 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

Code Description Validate Generate
BIK Bank Identification Code (БИК) + +
INN Taxpayer Identification Number (ИНН) + +
KPP Tax Registration Reason Code (КПП) + +
OGRN Primary State Registration Number (ОГРН) + +
OGRNIP Primary State Registration Number for IE (ОГРНИП) + +
SNILS Insurance Individual Account Number (СНИЛС) + +
OKATO Russian 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")
if err != 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)
if err != 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 types
legalINN := inn.GenerateLegal()
physicalINN := inn.GeneratePhysical()

// Validate
ok, 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

  • INN (ИНН)
  • SNILS (СНИЛС)
  • OGRN (ОГРН)
  • OGRNIP (ОГРНИП)
  • BIK (БИК)
  • KPP (КПП)

License

MIT

Documentation ¶

Index ¶

  • Variables
  • func Generate(docType DocType) (string, error)
  • func Validate(docType DocType, code string) (bool, error)
  • type DocType
  • type GenerateFunc
  • type ValidateFunc

Constants ¶

This section is empty.

Variables ¶

View Source
var ErrUnsupportedDocType = errors.New("unsupported document type")

ErrUnsupportedDocType is returned by Validate and Generate when the provided DocType is not one of the supported document types.

Functions ¶

func Generate ¶

func Generate(docType DocType) (string, error)

func Validate ¶

func Validate(docType DocType, code string) (bool, error)

Types ¶

type DocType ¶

type DocType uint
const (
	BIK DocType = iota
	INN
	KPP
	OGRN
	OGRNIP
	SNILS
)

type GenerateFunc ¶

type GenerateFunc func() string

type ValidateFunc ¶

type ValidateFunc func(code string) (bool, error)

Source Files ¶

View all Source files
  • errors.go
  • generate.go
  • types.go
  • validate.go

Directories ¶

Path Synopsis
bik
fts
inn
kpp
models
ogrn
ogrnip
okato
parser
bik command
fns command
subjects module
snils
utils
Click to show internal directories.
Click to hide internal directories.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.