rossn

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 28, 2025 License: MIT Imports: 5 Imported by: 0

README

rossn

Go Reference MIT License

rossn is a production-ready, permissively-licensed Go package for validating Romanian CNP (Personal Numeric Code) numbers.
It checks CNP structure, birth date, county, serial number, and official checksum.
Thoroughly tested against all official rules and edge cases.


Features

  • Validates CNP length, digits, date, county, serial (001–999), and checksum
  • Full support for archival Bucharest codes 47/48 (historical), and for code 70 for foreign/stateless residents (S=7,8,9 only), as per cnp-spec and Wikipedia.
  • Full support for SIIEASC JJ=70 (2024+) as per the official statement of the Romanian Ministry of Internal Affairs, May 2024
  • 100% Go, no dependencies
  • MIT licensed: Free for commercial and closed-source use
  • Fast, robust, and tested

Install

go get github.com/ac999/rossn

Usage

package main

import (
    "fmt"
    "github.com/ac99/rossn"
)

func main() {
    err := rossn.Validate("1981214320015")
    if err != nil {
        fmt.Println("Invalid CNP:", err)
    } else {
        fmt.Println("Valid CNP!")
    }
}

CNP Specification

A CNP is 13 digits: SYYMMDDJJNNNC

  • S: Gender and century
  • YYMMDD: Date of birth (with S determining the century)
  • JJ: County code (01–52, official list)
  • NNN: Serial number (001–999)
  • C: Control digit (checksum, see here)

All checks are performed according to the official Romanian government rules.

Testing

Run all tests with:

go test ./...

Or for detailed output:

go test -v

Contributing

Pull requests and issue reports are welcome! Before submitting, make sure all tests pass and that new edge cases are covered by tests.


License

MIT License — see LICENSE


References

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validate

func Validate(cnp string) error

Validate checks if a CNP is valid according to all official Romanian rules. It verifies length, digit content, date, county, serial, and checksum. Returns nil if valid, or an error describing the failure.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL