mpetruska / uk-modulo-scala

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

Version Matrix

Build Status Known Vulnerabilities

UK modulo - Scala

This is an implementation of the VocaLink UK Bank account number modulus checking version 6.12 (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


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





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")



// 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";


Please report issues and feature requests here.

Version history