Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including euro-banknote-serialnumber with all npm packages installed. Try it out:

var euroBanknoteSerialnumber = require("euro-banknote-serialnumber")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

euro-banknote-serialnumber v0.1.1

verify a euro banknote serial number

Euro banknote serialnumber

ZERO DEPENDENCIES

This module will verify/validate that a given serial number is a valid Euro banknote serial number.

The list of allowed country codes (and corresponding checksum digits) can be found in this wikipedia page.

I converted this to javascript from an old C assignment I did at university, see /old_c/checksum.c.

Install

To use in a node application:

npm install euro-banknote-serialnumber

To use as a cli tool

npm install -g euro-banknote-serialnumber

Usage

In a node application:

const euroBanknoteSN = require("euro-banknote-serialnumber")

const check1 = euroBanknoteSN.verify("L25388049086")
// check1 === false (it's invalid)

const check2 = euroBanknoteSN.verify("X30284111711")
// check2 === true (it's a valid series 1 banknote serial number)

const check3 = euroBanknoteSN.verify("NA4532489209")
// check3 === true (it's a valid series 2 banknote serial number)

As a cli tool:

euro-banknote-serialnumber --help
euro-banknote-serialnumber -h
euro-banknote-serialnumber
# outputs help about the command

euro-banknote-serialnumber --verify L25388049086
# outputs 'invalid' and return code is 1 (so you can use it in pipes)

euro-banknote-serialnumber --verify X30284111711
# outputs 'valid: X30284111711' and return code 0 (so you can use it in pipes)

euro-banknote-serialnumber --verify NA4532489209
# outputs 'valid: NA4532489209' and return code 0 (so you can use it in pipes)

License

MIT

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free