How to validate BSN, PGN & OWN in the Netherlands with TypeScript/JavaScript

Learn How To Use The Elfproef for dutch identification numbers

ยท

2 min read

How to validate BSN, PGN & OWN in the Netherlands with TypeScript/JavaScript

Photo by Denise Jans on Unsplash

The BSN, PGN and OWN in the Netherlands can be validated with a 11 proef (elf proef). In this post I show you the JavaScript and TypeScript code.

In the Netherlands, we have a few identification numbers from the government. In this example, you can create a function to validate both of them based on the specification.

  • BSN = Burgerservice nummer
  • PGN = Burgerservice nummer in schools where the student doesn't have a BSN. The PGN is also called OWN.

divider-byrayray.png

How to use the code?

Define the function in your code and call it like this:

TypeScript example

// PGN/OWN
elfProefValidation('114435231', ElfproefType.own); // returns true;
elfProefValidation('34564366349', ElfproefType.own); // returns false;
// BSN
elfProefValidation('232262536', ElfproefType.bsn); // returns true;
elfProefValidation('247594057', ElfproefType.bsn); // returns false;

JavaScript example

// PGN/OWN
elfProefValidation('114435231', 'own'); // returns true;
elfProefValidation('34564366349', 'own')); // returns false;
// BSN
elfProefValidation('232262536', 'bsn')); // returns true;
elfProefValidation('247594057', 'bsn')); // returns false;

Working version

I created a working version on RunKit . Make sure you select Node version 17.

Code

divider-byrayray.png

Thanks!

hashnode-footer.png I hope you learned something new or are inspired to create something new after reading this story! ๐Ÿค— If so, consider subscribing via email (scroll to the top of this page) or follow me here on Hashnode.

Did you know that you can create a Developer blog like this one, yourself? It's entirely for free. ๐Ÿ‘๐Ÿ’ฐ๐ŸŽ‰๐Ÿฅณ๐Ÿ”ฅ

If I left you with questions or something to say as a response, scroll down and type me a message. Please send me a DM on Twitter @DevByRayRay when you want to keep it private. My DM's are always open ๐Ÿ˜

Did you find this article valuable?

Support Dev By RayRay by becoming a sponsor. Any amount is appreciated!

ย