npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@tarikkoc/national-id-validation

v1.1.3

Published

Validate Turkish Identification Numbers (TCKN) with algorithm checks.

Downloads

28

Readme

@tarikkoc/national-id-validation

Validate national identification numbers (TCKN, DNI, PESEL, CPF, SSN* ) with checksum/format rules.
TypeScript types included. Zero dependency. Lightweight.
*SSN is format-only (no issuance database checks).

npm version npm downloads License: ISC GitHub


Features

  • TR – TCKN: official checksum rules (10th & 11th digits)
  • ES – DNI: checksum letter ("TRWAGMYFPDXBNJZSQVHLCKE"[num % 23])
  • PL – PESEL: checksum with weights [1,3,7,9,1,3,7,9,1,3] (rejects letters; allows spaces/hyphens)
  • BR – CPF: two-stage check digits (10..2 then 11..2), rejects repeated-digit sequences
  • US – SSN: format-only validation with blocked ranges (000, 666, 9xx; group=00; serial=0000)
  • isValidNationalID(country, value) convenience switch
  • 🧪 Test suite with Vitest
  • 🧩 Zero dependencies

Install

npm i @tarikkoc/national-id-validation
# yarn add @tarikkoc/national-id-validation
# pnpm add @tarikkoc/national-id-validation

Usage

CommonJS

const {
  isValidTCKN,
  isValidDNI,
  isValidPESEL,
  isValidCPF,
  isValidSSN,
} = require("@tarikkoc/national-id-validation");

console.log(isValidTCKN("10000000146")); // true
console.log(isValidDNI("12345678Z")); // true
console.log(isValidPESEL("44051401458")); // true
console.log(isValidCPF("529.982.247-25")); // true
console.log(isValidSSN("123-45-6789")); // true (format-only)

ES Modules / TypeScript

import {
  isValidTCKN,
  isValidDNI,
  isValidPESEL,
  isValidCPF,
  isValidSSN,
} from "@tarikkoc/national-id-validation";

const ok = isValidTCKN("12345678Z"); // boolean

API

  • isValidTCKN(tckn: string): boolean
    11 digits; first digit must not be 0; 10th & 11th digits are checksums.

  • isValidDNI(dni: string): boolean
    NNNNNNNN-L (letter = "TRWAGMYFPDXBNJZSQVHLCKE"[num % 23]). Tolerates - and whitespace.

  • isValidPESEL(pesel: string): boolean
    11 digits; check digit with weights [1,3,7,9,1,3,7,9,1,3]. Rejects non-digit chars (spaces/hyphens ignored).

  • isValidCPF(cpf: string): boolean
    11 digits; two-stage check digits (10..2, then 11..2). Rejects repeated-digit sequences; dots/hyphens ignored.

  • isValidSSN(ssn: string): boolean (format-only)
    Accepts AAA-GG-SSSS or 9 digits; rejects blocked ranges (000, 666, 9xx; group=00; serial=0000).

Disclaimer: This library validates format and checksum rules only. It does not confirm issuance/assignment by any authority.


What’s new in 1.1.0

  • Package renamed: @tarikkoc/check-tckn-num@tarikkoc/national-id-validation
  • New validators: ES (DNI), PL (PESEL), BR (CPF), US (SSN format)
  • No breaking change for TCKN users — keep using isValidTCKN

Migration

- import { isValidTCKN } from "@tarikkoc/check-tckn-num";
+ import { isValidTCKN } from "@tarikkoc/national-id-validation";

(Optional) Deprecate the old package on npm:

npm deprecate @tarikkoc/check-tckn-num@"<1.1.0" "Renamed to @tarikkoc/national-id-validation"

License

ISC © Tarik Koc