+
Skip to content
/ rossn Public

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.

License

Notifications You must be signed in to change notification settings

ac999/rossn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

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

License

Stars

Watchers

Forks

Packages

No packages published

Languages

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载