File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -199,6 +199,10 @@ export default class UkModulusChecking {
199199 */
200200
201201 isValid ( ) {
202+ if ( this . accountNumber . length < 6 || this . accountNumber . length > 10 || this . sortCode . length !== 6 ) {
203+ return false ;
204+ }
205+
202206 const checks = this . getSortCodeChecks ( ) ;
203207
204208 // If no range is found that contains the sorting code, there is no modulus check that can be performed.
Original file line number Diff line number Diff line change @@ -52,6 +52,18 @@ const accounts = {
5252
5353describe ( 'UkModulusChecking' , ( ) => {
5454 describe ( 'isValid()' , ( ) => {
55+ it ( 'should return false if account number length is less than 6' , ( ) => {
56+ new UkModulusChecking ( { accountNumber : '12345' , sortCode : '123456' } ) . isValid ( ) . should . be . false ( ) ;
57+ } ) ;
58+
59+ it ( 'should return false if account number length is greater than 10' , ( ) => {
60+ new UkModulusChecking ( { accountNumber : '12345678901' , sortCode : '123456' } ) . isValid ( ) . should . be . false ( ) ;
61+ } ) ;
62+
63+ it ( 'should return false if sort code length is not 6' , ( ) => {
64+ new UkModulusChecking ( { accountNumber : '12345789' , sortCode : '12345' } ) . isValid ( ) . should . be . false ( ) ;
65+ } ) ;
66+
5567 accounts . invalid . forEach ( ( account ) => {
5668 it ( `should return false if sort code is ${ account . sortCode } and account number is ${ account . accountNumber } ` , ( ) => {
5769 new UkModulusChecking ( { accountNumber : account . accountNumber , sortCode : account . sortCode } ) . isValid ( ) . should . be . false ( ) ;
You can’t perform that action at this time.
0 commit comments