Skip to content

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

License

Notifications You must be signed in to change notification settings

mpetruska/uk-modulo-scala

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Known Vulnerabilities

UK modulo - Scala

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

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

Notes on validating sort codes

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

Getting started

Sbt:

libraryDependencies += "com.github.mpetruska" %% "uk-modulo-scala" % "6.80.0"

pom.xml:

<dependency>
  <groupId>com.github.mpetruska</groupId>
  <artifactId>uk-modulo-scala_2.13</artifactId>
  <version>6.80.0</version>
</dependency>

Usage

Scala:

import com.github.mpetruska.ukmodulo.ModulusCheck

// valid account number
ModulusCheck.check(sortCode = "089999", accountNumber = "66374958") === Right(true)

// invalid account number
ModulusCheck.check(sortCode = "089999", accountNumber = "66374959") === Right(false)

// invalid format
ModulusCheck.check(sortCode = "089999", accountNumber = "xxxx") === Left("Account number format is not valid")

Java:

import com.github.mpetruska.ukmodulo.java.ModulusCheck;
import com.github.mpetruska.ukmodulo.java.ModulusCheckResult;

// valid account number
new ModulusCheck().check("089999", "66374958").isValidAccountNumber() == true;

// invalid account number
ModulusCheckResult result = new ModulusCheck().check("089999", "66374959");
result.isValidAccountNumber() == false;
result.isError() == false;

// invalid format
ModulusCheckResult result2 = new ModulusCheck().check("089999", "xxxx");
result2.isError() == true;
result2.error() == "Account number format is not valid";

Issues

Please report issues and feature requests here.

Version history

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages