JSPM

bsn-validator

1.0.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 146
  • Score
    100M100P100Q74236F
  • License MIT

A simple validator for Dutch BSN (Burgerservicenummer)

Package Exports

  • bsn-validator
  • bsn-validator/dist/index.js
  • bsn-validator/dist/index.mjs

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (bsn-validator) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

bsn-validator

A tiny TypeScript/JavaScript package for validating Dutch BSN (Burgerservicenummer) numbers and generating fake BSNs for testing.

Install

npm

npm install bsn-validator

CDN

<script src="https://cdn.jsdelivr.net/npm/bsn-validator/dist/index.global.js"></script>

Quick Start

JavaScript

const { isValidBSN, generateFakeBSN } = require("bsn-validator");
const input = "123456782";
const fakeBSN = generateFakeBSN();

if (isValidBSN(input)) {
  console.log("Valid BSN");
}

console.log(fakeBSN);

TypeScript / ESM

import { isValidBSN, generateFakeBSN } from "bsn-validator";

const input = "123456782";
const fakeBSN = generateFakeBSN();

if (isValidBSN(input)) {
  console.log("Valid BSN");
}

console.log(fakeBSN);

CDN

<script src="https://cdn.jsdelivr.net/npm/bsn-validator/dist/index.global.js"></script>
<script>
  const input = "123456782";
  const fakeBSN = bsnValidator.generateFakeBSN();

  if (bsnValidator.isValidBSN(input)) {
    console.log("Valid BSN");
  }

  console.log(fakeBSN);
</script>

API

isValidBSN(bsn: string): boolean

Validates a BSN using the Dutch 11-check.

Rules:

  • Accepts only 8 or 9 digits.
  • Ignores leading/trailing spaces.
  • Returns true when the number passes the 11-check, otherwise false.

generateFakeBSN(): string

Generates a fake BSN-like value intended for testing and development.

Notes:

  • Generated values may coincide with a real BSN they are not guaranteed to be fictitious.
  • The generated values are primarily intended for testing the application you are developing, not for real identity or production workflows.

Use Cases

  • Form input validation for Dutch BSN fields.
  • Backend request validation before processing.
  • Creating mock BSN data for tests and demos.

References

License

MIT