PHPackages                             cs278/bank-modulus - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. cs278/bank-modulus

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

cs278/bank-modulus
==================

UK Bank Modulus Check Library

v1.15.0(2y ago)32572.8k—4.7%7[1 issues](https://github.com/cs278/bank-modulus/issues)[2 PRs](https://github.com/cs278/bank-modulus/pulls)MITPHPPHP ^5.6 || ^7.2 || ^8.0

Since Feb 7Pushed 1y ago5 watchersCompare

[ Source](https://github.com/cs278/bank-modulus)[ Packagist](https://packagist.org/packages/cs278/bank-modulus)[ Docs](https://github.com/cs278/bank-modulus)[ RSS](/packages/cs278-bank-modulus/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (5)Versions (23)Used By (0)

UK Bank Modulus Check Library
=============================

[](#uk-bank-modulus-check-library)

[![Main](https://github.com/cs278/bank-modulus/workflows/Main/badge.svg?branch=master)](https://github.com/cs278/bank-modulus/actions)[![Build Status](https://camo.githubusercontent.com/804ac2cbe00503145a65159b09e92b74fbf1b6e55025eaec5d1e7c3e6a8562f5/68747470733a2f2f7472617669732d63692e6f72672f63733237382f62616e6b2d6d6f64756c75732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/cs278/bank-modulus)[![Latest Stable Version](https://camo.githubusercontent.com/13752bf9bdeb0dfb499291b0caade7fdb93151321a74a02d38a3895be2e520df/68747470733a2f2f706f7365722e707567782e6f72672f63733237382f62616e6b2d6d6f64756c75732f762f737461626c652e737667)](https://packagist.org/packages/cs278/bank-modulus)[![Total Downloads](https://camo.githubusercontent.com/7df35ea4abffdf8c46d045d5c89653206140b1134913b2a7a8d834263ec2391a/68747470733a2f2f706f7365722e707567782e6f72672f63733237382f62616e6b2d6d6f64756c75732f646f776e6c6f6164732e737667)](https://packagist.org/packages/cs278/bank-modulus)

This PHP library allows you to check the validity of UK bank account information. To perform this task it uses publicly available information and the specifications published by VocaLink.

You must be aware that this library cannot tell you that the account number and sort code associate to an active account, it only tells you that they *could* be assigned to an account. Neither does it cover all sort codes, some of which are outside the specification and you should assume those details are valid unless otherwise known.

Usage
-----

[](#usage)

### Basics

[](#basics)

This library provides a simple class to perform bank account validation and normalisation, through the `BankModulus` class.

By default the `BankModulus` class will use the current modulus specification issued by VocaLink, the default specification factory will pick the correct specification based on the date.

- `normalize(string &$sortCode, string &$accountNumber)`

    This performs normalisation of sort code and account numbers according to rules issued by some banks. As an example 6 digit account numbers get padded with two zeros.

    The result of normalisation is assigned back to the input parameters.
- `check(string $sortCode, string $accountNumber) : boolean`

    This is the primary method to ascertain if the details supplied are invalid, it returns `false` if the sort code and account number are invalid otherwise it will return `true`. If the details provided are syntactically valid but fall outside the specification then this method considers them valid.
- `lookup(string $sortCode, string $accountNumber) : Result`

    Use this method to fetch more in depth information on the sort code and account number. See documentation on the `Result` class for more information.
- `__construct(SpecFactoryInterface $specFactory, NormalizerInterface $normalizer)`

    You can change which specification factory and normalizer is used at the time of construction, otherwise defaults will be used.
- Example:

    ```
