Skip to content
ac999Public

About

Go package for validating Romanian CNP (Personal Numeric Code) — the Romanian social security number. Provides full format, date, county, and checksum validation, with a simple API.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Go package for validating Romanian CNP (Personal Numeric Code) — the Romanian social security number. Provides full format, date, county, and checksum validation, with a simple API.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages