Skip to content

A PureScript implementation of the VocaLink UK Bank account number modulus checking.

License

Notifications You must be signed in to change notification settings

mpetruska/uk-modulo-purescript

Repository files navigation

Build Status Known Vulnerabilities

UK modulo - PureScript

This is an implementation of the VocaLink UK Bank account number modulus checking 6.12 (and previous versions), written in PureScript.

Modulus checking is a procedure used to determine whether a bank account number can be valid. If the account number check is negative then the account cannot exist, but the opposite is not true (meaning that if the check succeeds that does not guarantee the existence of the account).

Modulus checking can be used to help detect some input errors, but unfortunately there can be user errors that remain undetected.

License: MIT

Demo page

Notes on validating sort codes

The "Industry Sorting Code Directory" (ISCD) should be used to validate UK sort codes.

Getting started

For PureScript projects:

npm install purescript --save-dev
bower install purescript-uk-modulo --save

Setting up gulp build for JavaScript projects:

npm install purescript --save-dev
bower install gulp-purescript --save-dev
bower install purescript-uk-modulo --save
"use strict";

var gulp = require("gulp"),
    purescript = require("gulp-purescript");

// PureScript sources
var sources = [
  "bower_components/purescript-*/src/**/*.purs"
];

// Build the PureScript sources and put resultant javascript files into output.
gulp.task("make", function() {
  return purescript.psc({
    src: sources
  });
});

gulp.task("default", ["make"]);

Usage

PureScript:

import Data.Either (Either(..))
import ModulusCheck (check)

-- valid account number
check "089999" "66374958" === Right true

-- invalid account number
check "089999" "66374959" === Right false

-- invalid format
check "089999" "xxxx" === Left "Account number format is not valid"

JavaScript:

// valid account number
PS.ModulusCheck.JavaScript.check("089999", "66374958").isValid === true;

// invalid account number
var result = PS.ModulusCheck.JavaScript.check("089999", "66374959");
result.isValid === false;
result.isError === false;

// invalid format
var result = PS.ModulusCheck.JavaScript.check("089999", "xxxx");
result.isError === true;
result.error === "Account number format is not valid";

Issues

Please report issues and feature requests here.

Version history

About

A PureScript implementation of the VocaLink UK Bank account number modulus checking.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages