From ce415a560751cfe5cfca8cae3d5e805d3c80dca2 Mon Sep 17 00:00:00 2001 From: edgarbjorntvedt Date: Mon, 21 Jan 2019 10:01:32 +0100 Subject: [PATCH] Published by publish-to-git 1d669f87f54f378d2645ec8b0f0c431e400ff269 (HEAD -> refs/heads/master, refs/remotes/origin/master) Extended format on the plus giro format --- dist/src/BankAccountValidation.d.ts | 9 + dist/src/BankAccountValidation.js | 24 + dist/src/BankAccountValidation.js.map | 1 + dist/src/IbanValidation.d.ts | 12 + dist/src/IbanValidation.js | 25 + dist/src/IbanValidation.js.map | 1 + dist/src/createBankAccountValidation.d.ts | 3 + dist/src/createBankAccountValidation.js | 19 + dist/src/createBankAccountValidation.js.map | 1 + dist/src/defaultConfig.d.ts | 2 + dist/src/defaultConfig.js | 4 + dist/src/defaultConfig.js.map | 1 + dist/src/index.d.ts | 2 + dist/src/index.js | 7 + dist/src/index.js.map | 1 + dist/src/types.d.ts | 14 + dist/src/types.js | 3 + dist/src/types.js.map | 1 + dist/src/util/banks.d.ts | 10 + dist/src/util/banks.js | 445 ++++++++++++++++++ dist/src/util/banks.js.map | 1 + dist/src/util/mod10.d.ts | 2 + dist/src/util/mod10.js | 32 ++ dist/src/util/mod10.js.map | 1 + dist/src/util/modulusCalculation.d.ts | 2 + dist/src/util/modulusCalculation.js | 27 ++ dist/src/util/modulusCalculation.js.map | 1 + dist/src/util/standarizeInput.d.ts | 2 + dist/src/util/standarizeInput.js | 23 + dist/src/util/standarizeInput.js.map | 1 + dist/src/util/swedishBanks.d.ts | 1 + dist/src/util/swedishBanks.js | 397 ++++++++++++++++ dist/src/util/swedishBanks.js.map | 1 + dist/src/validators/IbanValidation.d.ts | 11 + dist/src/validators/IbanValidation.js | 25 + dist/src/validators/IbanValidation.js.map | 1 + .../validators/NorwegianBbanValidation.d.ts | 11 + .../src/validators/NorwegianBbanValidation.js | 31 ++ .../validators/NorwegianBbanValidation.js.map | 1 + .../validators/SwedishBankgiroValidation.d.ts | 11 + .../validators/SwedishBankgiroValidation.js | 24 + .../SwedishBankgiroValidation.js.map | 1 + .../src/validators/SwedishBbanValidation.d.ts | 13 + dist/src/validators/SwedishBbanValidation.js | 68 +++ .../validators/SwedishBbanValidation.js.map | 1 + .../validators/SwedishPlusgiroValidation.d.ts | 11 + .../validators/SwedishPlusgiroValidation.js | 24 + .../SwedishPlusgiroValidation.js.map | 1 + dist/test/NO/testBbanValidation.d.ts | 1 + dist/test/NO/testBbanValidation.js | 48 ++ dist/test/NO/testBbanValidation.js.map | 1 + dist/test/SE/testBbanValidation.d.ts | 1 + dist/test/SE/testBbanValidation.js | 34 ++ dist/test/SE/testBbanValidation.js.map | 1 + .../SE/testSwedishBankgiroValidation.d.ts | 1 + dist/test/SE/testSwedishBankgiroValidation.js | 39 ++ .../SE/testSwedishBankgiroValidation.js.map | 1 + .../SE/testSwedishPlusgiroValidation.d.ts | 1 + dist/test/SE/testSwedishPlusgiroValidation.js | 74 +++ .../SE/testSwedishPlusgiroValidation.js.map | 1 + dist/test/testBankAccountValidation.d.ts | 1 + dist/test/testBankAccountValidation.js | 24 + dist/test/testBankAccountValidation.js.map | 1 + dist/test/testBankAccountValidation_.d.ts | 1 + dist/test/testBankAccountValidation_.js | 16 + dist/test/testBankAccountValidation_.js.map | 1 + dist/test/testIbanValidation.d.ts | 1 + dist/test/testIbanValidation.js | 39 ++ dist/test/testIbanValidation.js.map | 1 + dist/test/testSomething.d.ts | 1 + dist/test/testSomething.js | 12 + dist/test/testSomething.js.map | 1 + package.json | 67 +++ src/BankAccountValidation.ts | 28 ++ src/createBankAccountValidation.ts | 17 + src/defaultConfig.ts | 2 + src/index.ts | 2 + src/types.ts | 17 + src/util/modulusCalculation.ts | 28 ++ src/util/standarizeInput.ts | 22 + src/util/swedishBanks.ts | 394 ++++++++++++++++ src/validators/IbanValidation.ts | 31 ++ src/validators/NorwegianBbanValidation.ts | 37 ++ src/validators/SwedishBankgiroValidation.ts | 30 ++ src/validators/SwedishBbanValidation.ts | 97 ++++ src/validators/SwedishPlusgiroValidation.ts | 30 ++ 86 files changed, 2414 insertions(+) create mode 100644 dist/src/BankAccountValidation.d.ts create mode 100644 dist/src/BankAccountValidation.js create mode 100644 dist/src/BankAccountValidation.js.map create mode 100644 dist/src/IbanValidation.d.ts create mode 100644 dist/src/IbanValidation.js create mode 100644 dist/src/IbanValidation.js.map create mode 100644 dist/src/createBankAccountValidation.d.ts create mode 100644 dist/src/createBankAccountValidation.js create mode 100644 dist/src/createBankAccountValidation.js.map create mode 100644 dist/src/defaultConfig.d.ts create mode 100644 dist/src/defaultConfig.js create mode 100644 dist/src/defaultConfig.js.map create mode 100644 dist/src/index.d.ts create mode 100644 dist/src/index.js create mode 100644 dist/src/index.js.map create mode 100644 dist/src/types.d.ts create mode 100644 dist/src/types.js create mode 100644 dist/src/types.js.map create mode 100644 dist/src/util/banks.d.ts create mode 100644 dist/src/util/banks.js create mode 100644 dist/src/util/banks.js.map create mode 100644 dist/src/util/mod10.d.ts create mode 100644 dist/src/util/mod10.js create mode 100644 dist/src/util/mod10.js.map create mode 100644 dist/src/util/modulusCalculation.d.ts create mode 100644 dist/src/util/modulusCalculation.js create mode 100644 dist/src/util/modulusCalculation.js.map create mode 100644 dist/src/util/standarizeInput.d.ts create mode 100644 dist/src/util/standarizeInput.js create mode 100644 dist/src/util/standarizeInput.js.map create mode 100644 dist/src/util/swedishBanks.d.ts create mode 100644 dist/src/util/swedishBanks.js create mode 100644 dist/src/util/swedishBanks.js.map create mode 100644 dist/src/validators/IbanValidation.d.ts create mode 100644 dist/src/validators/IbanValidation.js create mode 100644 dist/src/validators/IbanValidation.js.map create mode 100644 dist/src/validators/NorwegianBbanValidation.d.ts create mode 100644 dist/src/validators/NorwegianBbanValidation.js create mode 100644 dist/src/validators/NorwegianBbanValidation.js.map create mode 100644 dist/src/validators/SwedishBankgiroValidation.d.ts create mode 100644 dist/src/validators/SwedishBankgiroValidation.js create mode 100644 dist/src/validators/SwedishBankgiroValidation.js.map create mode 100644 dist/src/validators/SwedishBbanValidation.d.ts create mode 100644 dist/src/validators/SwedishBbanValidation.js create mode 100644 dist/src/validators/SwedishBbanValidation.js.map create mode 100644 dist/src/validators/SwedishPlusgiroValidation.d.ts create mode 100644 dist/src/validators/SwedishPlusgiroValidation.js create mode 100644 dist/src/validators/SwedishPlusgiroValidation.js.map create mode 100644 dist/test/NO/testBbanValidation.d.ts create mode 100644 dist/test/NO/testBbanValidation.js create mode 100644 dist/test/NO/testBbanValidation.js.map create mode 100644 dist/test/SE/testBbanValidation.d.ts create mode 100644 dist/test/SE/testBbanValidation.js create mode 100644 dist/test/SE/testBbanValidation.js.map create mode 100644 dist/test/SE/testSwedishBankgiroValidation.d.ts create mode 100644 dist/test/SE/testSwedishBankgiroValidation.js create mode 100644 dist/test/SE/testSwedishBankgiroValidation.js.map create mode 100644 dist/test/SE/testSwedishPlusgiroValidation.d.ts create mode 100644 dist/test/SE/testSwedishPlusgiroValidation.js create mode 100644 dist/test/SE/testSwedishPlusgiroValidation.js.map create mode 100644 dist/test/testBankAccountValidation.d.ts create mode 100644 dist/test/testBankAccountValidation.js create mode 100644 dist/test/testBankAccountValidation.js.map create mode 100644 dist/test/testBankAccountValidation_.d.ts create mode 100644 dist/test/testBankAccountValidation_.js create mode 100644 dist/test/testBankAccountValidation_.js.map create mode 100644 dist/test/testIbanValidation.d.ts create mode 100644 dist/test/testIbanValidation.js create mode 100644 dist/test/testIbanValidation.js.map create mode 100644 dist/test/testSomething.d.ts create mode 100644 dist/test/testSomething.js create mode 100644 dist/test/testSomething.js.map create mode 100644 package.json create mode 100644 src/BankAccountValidation.ts create mode 100644 src/createBankAccountValidation.ts create mode 100644 src/defaultConfig.ts create mode 100644 src/index.ts create mode 100644 src/types.ts create mode 100644 src/util/modulusCalculation.ts create mode 100644 src/util/standarizeInput.ts create mode 100644 src/util/swedishBanks.ts create mode 100644 src/validators/IbanValidation.ts create mode 100644 src/validators/NorwegianBbanValidation.ts create mode 100644 src/validators/SwedishBankgiroValidation.ts create mode 100644 src/validators/SwedishBbanValidation.ts create mode 100644 src/validators/SwedishPlusgiroValidation.ts diff --git a/dist/src/BankAccountValidation.d.ts b/dist/src/BankAccountValidation.d.ts new file mode 100644 index 0000000..f01bd19 --- /dev/null +++ b/dist/src/BankAccountValidation.d.ts @@ -0,0 +1,9 @@ +import * as types from './types'; +import { ValidationInput } from "./types"; +export declare class BankAccountValidation { + _config: types.BankAccountValidationConfig; + _validationRules: types.IValidation[]; + constructor(config: Partial); + add(validationRule: types.IValidation): void; + validate(input: string | ValidationInput): types.ValidationResult[]; +} diff --git a/dist/src/BankAccountValidation.js b/dist/src/BankAccountValidation.js new file mode 100644 index 0000000..79eeb12 --- /dev/null +++ b/dist/src/BankAccountValidation.js @@ -0,0 +1,24 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const defaultsDeep = require("lodash.defaultsdeep"); +const defaultConfig_1 = require("./defaultConfig"); +class BankAccountValidation { + constructor(config) { + this._config = defaultsDeep({}, config, defaultConfig_1.default); + this._validationRules = []; + } + add(validationRule) { + this._validationRules.push(validationRule); + } + validate(input) { + return this._validationRules + .filter(validationRule => { + return validationRule.canValidate(input); + }) + .map(validationRule => { + return validationRule.validate(input); + }); + } +} +exports.BankAccountValidation = BankAccountValidation; +//# sourceMappingURL=BankAccountValidation.js.map \ No newline at end of file diff --git a/dist/src/BankAccountValidation.js.map b/dist/src/BankAccountValidation.js.map new file mode 100644 index 0000000..11be4d2 --- /dev/null +++ b/dist/src/BankAccountValidation.js.map @@ -0,0 +1 @@ +{"version":3,"file":"BankAccountValidation.js","sourceRoot":"","sources":["../../src/BankAccountValidation.ts"],"names":[],"mappings":";;AACA,oDAAoD;AACpD,mDAA2C;AAG3C,MAAa,qBAAqB;IAI9B,YAAY,MAAkD;QAC1D,IAAI,CAAC,OAAO,GAAG,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,uBAAa,CAAC,CAAA;QACtD,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAA;IAC9B,CAAC;IAED,GAAG,CAAC,cAAiC;QACjC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;IAC9C,CAAC;IAED,QAAQ,CAAC,KAA4B;QACjC,OAAO,IAAI,CAAC,gBAAgB;aACvB,MAAM,CAAC,cAAc,CAAC,EAAE;YACrB,OAAO,cAAc,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;QAC5C,CAAC,CAAC;aACD,GAAG,CAAC,cAAc,CAAC,EAAE;YAClB,OAAO,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QACzC,CAAC,CAAC,CAAA;IACV,CAAC;CACJ;AAtBD,sDAsBC"} \ No newline at end of file diff --git a/dist/src/IbanValidation.d.ts b/dist/src/IbanValidation.d.ts new file mode 100644 index 0000000..e06e8d9 --- /dev/null +++ b/dist/src/IbanValidation.d.ts @@ -0,0 +1,12 @@ +import * as types from './types'; +import { IValidation, ValidationInput } from './types'; +export declare class IbanValidation implements IValidation { + _config: types.BankAccountValidationConfig; + _validationRules: types.IValidation[]; + private _ibanTester; + constructor(config: Partial); + canValidate(input: string | ValidationInput): Boolean; + validate(input: string | ValidationInput): { + valid: boolean; + }; +} diff --git a/dist/src/IbanValidation.js b/dist/src/IbanValidation.js new file mode 100644 index 0000000..80df646 --- /dev/null +++ b/dist/src/IbanValidation.js @@ -0,0 +1,25 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const defaultConfig_1 = require("./defaultConfig"); +const ibantools = require("ibantools"); +const standarizeInput_1 = require("./util/standarizeInput"); +const defaultsDeep = require("lodash.defaultsdeep"); +class IbanValidation { + constructor(config) { + this._config = defaultsDeep({}, config, defaultConfig_1.default); + this._validationRules = []; + this._ibanTester = /^[A-Z]{2}.*$/; + } + canValidate(input) { + input = standarizeInput_1.standarizeInput(input); + return input && this._ibanTester.test(input.accountNumber); + } + validate(input) { + input = standarizeInput_1.standarizeInput(input); + return { + valid: ibantools.isValidIBAN(input.accountNumber) + }; + } +} +exports.IbanValidation = IbanValidation; +//# sourceMappingURL=IbanValidation.js.map \ No newline at end of file diff --git a/dist/src/IbanValidation.js.map b/dist/src/IbanValidation.js.map new file mode 100644 index 0000000..ce954b6 --- /dev/null +++ b/dist/src/IbanValidation.js.map @@ -0,0 +1 @@ +{"version":3,"file":"IbanValidation.js","sourceRoot":"","sources":["../../src/IbanValidation.ts"],"names":[],"mappings":";;AAEA,mDAA2C;AAC3C,uCAAsC;AACtC,4DAAsD;AACtD,oDAAoD;AAEpD,MAAa,cAAc;IAKvB,YAAY,MAAkD;QAC1D,IAAI,CAAC,OAAO,GAAG,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,uBAAa,CAAC,CAAA;QACtD,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAA;QAC1B,IAAI,CAAC,WAAW,GAAG,cAAc,CAAA;IACrC,CAAC;IAED,WAAW,CAAC,KAA6B;QACrC,KAAK,GAAG,iCAAe,CAAC,KAAK,CAAC,CAAA;QAE9B,OAAO,KAAK,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;IAC9D,CAAC;IAED,QAAQ,CAAC,KAA4B;QACjC,KAAK,GAAG,iCAAe,CAAC,KAAK,CAAC,CAAA;QAE9B,OAAO;YACH,KAAK,EAAE,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,aAAa,CAAC;SACpD,CAAA;IACL,CAAC;CACJ;AAxBD,wCAwBC"} \ No newline at end of file diff --git a/dist/src/createBankAccountValidation.d.ts b/dist/src/createBankAccountValidation.d.ts new file mode 100644 index 0000000..2bcccec --- /dev/null +++ b/dist/src/createBankAccountValidation.d.ts @@ -0,0 +1,3 @@ +import { BankAccountValidation } from '../src'; +import * as types from "./types"; +export declare function createValidationWithAllAvailableValidators(config: Partial): BankAccountValidation; diff --git a/dist/src/createBankAccountValidation.js b/dist/src/createBankAccountValidation.js new file mode 100644 index 0000000..bcb309f --- /dev/null +++ b/dist/src/createBankAccountValidation.js @@ -0,0 +1,19 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const src_1 = require("../src"); +const SwedishBankgiroValidation_1 = require("./validators/SwedishBankgiroValidation"); +const SwedishPlusgiroValidation_1 = require("./validators/SwedishPlusgiroValidation"); +const SwedishBbanValidation_1 = require("./validators/SwedishBbanValidation"); +const NorwegianBbanValidation_1 = require("./validators/NorwegianBbanValidation"); +const IbanValidation_1 = require("./validators/IbanValidation"); +function createValidationWithAllAvailableValidators(config) { + let bankAccountValidation = new src_1.BankAccountValidation(config); + bankAccountValidation.add(new IbanValidation_1.IbanValidation(config)); + bankAccountValidation.add(new SwedishBankgiroValidation_1.SwedishBankgiroValidation(config)); + bankAccountValidation.add(new SwedishPlusgiroValidation_1.SwedishPlusgiroValidation(config)); + bankAccountValidation.add(new SwedishBbanValidation_1.SwedishBbanValidation(config)); + bankAccountValidation.add(new NorwegianBbanValidation_1.NorwegianBbanValidation(config)); + return bankAccountValidation; +} +exports.createValidationWithAllAvailableValidators = createValidationWithAllAvailableValidators; +//# sourceMappingURL=createBankAccountValidation.js.map \ No newline at end of file diff --git a/dist/src/createBankAccountValidation.js.map b/dist/src/createBankAccountValidation.js.map new file mode 100644 index 0000000..d22635c --- /dev/null +++ b/dist/src/createBankAccountValidation.js.map @@ -0,0 +1 @@ +{"version":3,"file":"createBankAccountValidation.js","sourceRoot":"","sources":["../../src/createBankAccountValidation.ts"],"names":[],"mappings":";;AAAA,gCAA8C;AAE9C,sFAAgF;AAChF,sFAAgF;AAChF,8EAAwE;AACxE,kFAA4E;AAC5E,gEAA0D;AAE1D,SAAgB,0CAA0C,CAAC,MAAkD;IACzG,IAAI,qBAAqB,GAAG,IAAI,2BAAqB,CAAC,MAAM,CAAC,CAAA;IAC7D,qBAAqB,CAAC,GAAG,CAAC,IAAI,+BAAc,CAAC,MAAM,CAAC,CAAC,CAAA;IACrD,qBAAqB,CAAC,GAAG,CAAC,IAAI,qDAAyB,CAAC,MAAM,CAAC,CAAC,CAAA;IAChE,qBAAqB,CAAC,GAAG,CAAC,IAAI,qDAAyB,CAAC,MAAM,CAAC,CAAC,CAAA;IAChE,qBAAqB,CAAC,GAAG,CAAC,IAAI,6CAAqB,CAAC,MAAM,CAAC,CAAC,CAAA;IAC5D,qBAAqB,CAAC,GAAG,CAAC,IAAI,iDAAuB,CAAC,MAAM,CAAC,CAAC,CAAA;IAC9D,OAAO,qBAAqB,CAAA;AAChC,CAAC;AARD,gGAQC"} \ No newline at end of file diff --git a/dist/src/defaultConfig.d.ts b/dist/src/defaultConfig.d.ts new file mode 100644 index 0000000..d87c485 --- /dev/null +++ b/dist/src/defaultConfig.d.ts @@ -0,0 +1,2 @@ +declare const _default: {}; +export default _default; diff --git a/dist/src/defaultConfig.js b/dist/src/defaultConfig.js new file mode 100644 index 0000000..bb37308 --- /dev/null +++ b/dist/src/defaultConfig.js @@ -0,0 +1,4 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = {}; +//# sourceMappingURL=defaultConfig.js.map \ No newline at end of file diff --git a/dist/src/defaultConfig.js.map b/dist/src/defaultConfig.js.map new file mode 100644 index 0000000..968e241 --- /dev/null +++ b/dist/src/defaultConfig.js.map @@ -0,0 +1 @@ +{"version":3,"file":"defaultConfig.js","sourceRoot":"","sources":["../../src/defaultConfig.ts"],"names":[],"mappings":";;AAAA,kBAAe,EACd,CAAA"} \ No newline at end of file diff --git a/dist/src/index.d.ts b/dist/src/index.d.ts new file mode 100644 index 0000000..0f49fa1 --- /dev/null +++ b/dist/src/index.d.ts @@ -0,0 +1,2 @@ +export { BankAccountValidation } from './BankAccountValidation'; +export { createValidationWithAllAvailableValidators } from './createBankAccountValidation'; diff --git a/dist/src/index.js b/dist/src/index.js new file mode 100644 index 0000000..7f822c3 --- /dev/null +++ b/dist/src/index.js @@ -0,0 +1,7 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var BankAccountValidation_1 = require("./BankAccountValidation"); +exports.BankAccountValidation = BankAccountValidation_1.BankAccountValidation; +var createBankAccountValidation_1 = require("./createBankAccountValidation"); +exports.createValidationWithAllAvailableValidators = createBankAccountValidation_1.createValidationWithAllAvailableValidators; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/src/index.js.map b/dist/src/index.js.map new file mode 100644 index 0000000..ce5f419 --- /dev/null +++ b/dist/src/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;AAAA,iEAA6D;AAArD,wDAAA,qBAAqB,CAAA;AAC7B,6EAAwF;AAAhF,mFAAA,0CAA0C,CAAA"} \ No newline at end of file diff --git a/dist/src/types.d.ts b/dist/src/types.d.ts new file mode 100644 index 0000000..6a7a438 --- /dev/null +++ b/dist/src/types.d.ts @@ -0,0 +1,14 @@ +export interface BankAccountValidationConfig { +} +export interface ValidationInput { + accountNumber: string; + countryCode?: string; + type?: string; +} +export interface ValidationResult { + valid: Boolean; +} +export interface IValidation { + validate(input: any): ValidationResult; + canValidate(input: any): Boolean; +} diff --git a/dist/src/types.js b/dist/src/types.js new file mode 100644 index 0000000..11e638d --- /dev/null +++ b/dist/src/types.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/dist/src/types.js.map b/dist/src/types.js.map new file mode 100644 index 0000000..7b5fff8 --- /dev/null +++ b/dist/src/types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/src/util/banks.d.ts b/dist/src/util/banks.d.ts new file mode 100644 index 0000000..dc6da2a --- /dev/null +++ b/dist/src/util/banks.d.ts @@ -0,0 +1,10 @@ +declare const _default: { + "bank": string; + "clearingFrom": number; + "n": string; + "clearingTo": number; + "format": string; + "type": number; + "comment": number; +}[]; +export = _default; diff --git a/dist/src/util/banks.js b/dist/src/util/banks.js new file mode 100644 index 0000000..76a58b0 --- /dev/null +++ b/dist/src/util/banks.js @@ -0,0 +1,445 @@ +"use strict"; +module.exports = [ + { + "bank": "Amfa Bank AB", + "clearingFrom": 9660, + "n": "-", + "clearingTo": 9669, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Avanza Bank AB (deltar endast i dataclearingen, ej i bankgirosystemet)", + "clearingFrom": 9550, + "n": "-", + "clearingTo": 9569, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "BlueStep Finans AB (deltar endast i dataclearingen, ej i Bankgirosystemet)", + "clearingFrom": 9680, + "n": "-", + "clearingTo": 9689, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "BNP Paribas Fortis Bank", + "clearingFrom": 9470, + "n": "-", + "clearingTo": 9479, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Citibank", + "clearingFrom": 9040, + "n": "-", + "clearingTo": 9049, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Danske Bank", + "clearingFrom": 1200, + "n": "-", + "clearingTo": 1399, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "Danske Bank", + "clearingFrom": 2400, + "n": "-", + "clearingTo": 2499, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "DNB Bank", + "clearingFrom": 9190, + "n": "-", + "clearingTo": 9199, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "DNB Bank", + "clearingFrom": 9260, + "n": "-", + "clearingTo": 9269, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Ekobanken", + "clearingFrom": 9700, + "n": "-", + "clearingTo": 9709, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Erik Penser AB (deltar endast i dataclearingen, ej i bankgirosystemet)", + "clearingFrom": 9590, + "n": "-", + "clearingTo": 9599, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Forex Bank", + "clearingFrom": 9400, + "n": "-", + "clearingTo": 9449, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "ICA Banken AB", + "clearingFrom": 9270, + "n": "-", + "clearingTo": 9279, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "IKANO Bank", + "clearingFrom": 9170, + "n": "-", + "clearingTo": 9179, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "JAK Medlemsbank (deltar endast i dataclearingen, ej i bankgirosystemet)", + "clearingFrom": 9670, + "n": "-", + "clearingTo": 9679, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Landshypotek AB (deltar endast i dataclearingen, ej i bankgirosystemet)", + "clearingFrom": 9390, + "n": "-", + "clearingTo": 9399, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "L%uFFFDn & Spar Bank Sverige (deltar endast i dataclearingen, ej i bankgirosystemet)", + "clearingFrom": 9630, + "n": "-", + "clearingTo": 9639, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "L%uFFFDnsf%uFFFDrs%uFFFDkringar Bank", + "clearingFrom": 3400, + "n": "-", + "clearingTo": 3409, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "L%uFFFDnsf%uFFFDrs%uFFFDkringar Bank", + "clearingFrom": 9020, + "n": "-", + "clearingTo": 9029, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "L%uFFFDnsf%uFFFDrs%uFFFDkringar Bank", + "clearingFrom": 9060, + "n": "-", + "clearingTo": 9069, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "Marginalen Bank", + "clearingFrom": 9230, + "n": "-", + "clearingTo": 9239, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "Nordax Bank AB", + "clearingFrom": 9640, + "n": "-", + "clearingTo": 9649, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Nordea", + "clearingFrom": 1100, + "n": "-", + "clearingTo": 1199, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "Nordea", + "clearingFrom": 1400, + "n": "-", + "clearingTo": 2099, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "Nordea (exkl. personkonton, cl 3300)", + "clearingFrom": 3000, + "n": "-", + "clearingTo": 3399, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "Nordea (exkl. personkonton, cl 3782)", + "clearingFrom": 3410, + "n": "-", + "clearingTo": 3999, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "Nordea", + "clearingFrom": 4000, + "n": "-", + "clearingTo": 4999, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Nordnet Bank", + "clearingFrom": 9100, + "n": "-", + "clearingTo": 9109, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Resurs Bank", + "clearingFrom": 9280, + "n": "-", + "clearingTo": 9289, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "Riksg%uFFFDlden", + "clearingFrom": 9880, + "n": "-", + "clearingTo": 9889, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Royal bank of Scotland", + "clearingFrom": 9090, + "n": "-", + "clearingTo": 9099, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Santander Consumer Bank AS (deltar endast i dataclearingen, ej i bankgirosystemet)", + "clearingFrom": 9460, + "n": "-", + "clearingTo": 9469, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "SBAB", + "clearingFrom": 9250, + "n": "-", + "clearingTo": 9259, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "SEB", + "clearingFrom": 5000, + "n": "-", + "clearingTo": 5999, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "SEB", + "clearingFrom": 9120, + "n": "-", + "clearingTo": 9124, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "SEB", + "clearingFrom": 9130, + "n": "-", + "clearingTo": 9149, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "Skandiabanken", + "clearingFrom": 9150, + "n": "-", + "clearingTo": 9169, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Swedbank", + "clearingFrom": 7000, + "n": "-", + "clearingTo": 7999, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "%uFFFDlandsbanken Sverige AB", + "clearingFrom": 2300, + "n": "-", + "clearingTo": 2399, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Danske Bank", + "clearingFrom": 9180, + "n": "-", + "clearingTo": 9189, + "format": "00xxxxxxxxxC", + "type": 2, + "comment": 1 + }, + { + "bank": "Handelsbanken", + "clearingFrom": 6000, + "n": "-", + "clearingTo": 6999, + "format": "000xxxxxxxxC", + "type": 2, + "comment": 2 + }, + { + "bank": "Nordea/Plusgirot", + "clearingFrom": 9500, + "n": "-", + "clearingTo": 9549, + "format": "00xxxxxxxxxC", + "type": 2, + "comment": 3 + }, + { + "bank": "Nordea/Plusgirot", + "clearingFrom": 9960, + "n": "-", + "clearingTo": 9969, + "format": "00xxxxxxxxxC", + "type": 2, + "comment": 3 + }, + { + "bank": "Nordea - personkonto", + "clearingFrom": 3300, + "n": "-", + "clearingTo": 3782, + "format": "00xxxxxxxxxC", + "type": 2, + "comment": 1 + }, + { + "bank": "Riksg%uFFFDlden", + "clearingFrom": 9890, + "n": "-", + "clearingTo": 9899, + "format": "00xxxxxxxxxC", + "type": 2, + "comment": 1 + }, + { + "bank": "Sparbanken Syd", + "clearingFrom": 9570, + "n": "-", + "clearingTo": 9579, + "format": "00xxxxxxxxxC", + "type": 2, + "comment": 1 + }, + { + "bank": "Swedbank", + "clearingFrom": 8000, + "n": "-", + "clearingTo": 8999, + "format": "00xxxxxxxxxC", + "type": 2, + "comment": 3 + }, + { + "bank": "Swedbank (f.d. Sparbanken %uFFFDresund)", + "clearingFrom": 9300, + "n": "-", + "clearingTo": 9329, + "format": "00xxxxxxxxxC", + "type": 2, + "comment": 1 + }, + { + "bank": "Swedbank (f.d. Sparbanken %uFFFDresund)", + "clearingFrom": 9330, + "n": "-", + "clearingTo": 9349, + "format": "00xxxxxxxxxC", + "type": 2, + "comment": 1 + } +]; +//# sourceMappingURL=banks.js.map \ No newline at end of file diff --git a/dist/src/util/banks.js.map b/dist/src/util/banks.js.map new file mode 100644 index 0000000..514ab78 --- /dev/null +++ b/dist/src/util/banks.js.map @@ -0,0 +1 @@ +{"version":3,"file":"banks.js","sourceRoot":"","sources":["../../../src/util/banks.ts"],"names":[],"mappings":";AAAA,iBAAS;IACP;QACE,MAAM,EAAE,cAAc;QACtB,cAAc,EAAE,IAAI;QACpB,GAAG,EAAE,GAAG;QACR,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE,cAAc;QACxB,MAAM,EAAE,CAAC;QACT,SAAS,EAAE,CAAC;KACb;IACD;QACE,MAAM,EAAE,wEAAwE;QAChF,cAAc,EAAE,IAAI;QACpB,GAAG,EAAE,GAAG;QACR,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE,cAAc;QACxB,MAAM,EAAE,CAAC;QACT,SAAS,EAAE,CAAC;KACb;IACD;QACE,MAAM,EAAE,4EAA4E;QACpF,cAAc,EAAE,IAAI;QACpB,GAAG,EAAE,GAAG;QACR,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE,cAAc;QACxB,MAAM,EAAE,CAAC;QACT,SAAS,EAAE,CAAC;KACb;IACD;QACE,MAAM,EAAE,yBAAyB;QACjC,cAAc,EAAE,IAAI;QACpB,GAAG,EAAE,GAAG;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B,cAAc,EAAE,IAAI;QACpB,GAAG,EAAE,GAAG;QACR,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE,cAAc;QACxB,MAAM,EAAE,CAAC;QACT,SAAS,EAAE,CAAC;KACb;IACD;QACE,MAAM,EAAE,UAAU;QAClB,cAAc,EAAE,IAAI;QACpB,GAAG,EAAE,GAAG;QACR,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE,cAAc;QACxB,MAAM,EAAE,CAAC;QACT,SAAS,EAAE,CAAC;KACb;IACD;QACE,MAAM,EAAE,yCAAyC;QACjD,cAAc,EAAE,IAAI;QACpB,GAAG,EAAE,GAAG;QACR,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE,cAAc;QACxB,MAAM,EAAE,CAAC;QACT,SAAS,EAAE,CAAC;KACb;IACD;QACE,MAAM,EAAE,yCAAyC;QACjD,cAAc,EAAE,IAAI;QACpB,GAAG,EAAE,GAAG;QACR,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE,cAAc;QACxB,MAAM,EAAE,CAAC;QACT,SAAS,EAAE,CAAC;KACb;CACF,CAAA"} \ No newline at end of file diff --git a/dist/src/util/mod10.d.ts b/dist/src/util/mod10.d.ts new file mode 100644 index 0000000..fcc6107 --- /dev/null +++ b/dist/src/util/mod10.d.ts @@ -0,0 +1,2 @@ +export declare function mod10(number: string): boolean; +export declare function mod11(number: string): boolean; diff --git a/dist/src/util/mod10.js b/dist/src/util/mod10.js new file mode 100644 index 0000000..5f3a856 --- /dev/null +++ b/dist/src/util/mod10.js @@ -0,0 +1,32 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +function normaizeWeights(weights, length) { + let _weights = weights; + while (_weights.length < length) { + _weights = _weights.concat(weights); + } + while (_weights.length > length) { + _weights.shift(); + } + if (_weights.length !== length) + throw new Error('sdfsdf'); + return _weights; +} +function calculate(number, weights, modulus, postProcess = (n) => n) { + weights = normaizeWeights(weights, number.length); + let sum = 0; + for (let i = 0; i++; i < number.length) { + sum += postProcess(parseInt(number[i]) * weights[i]); + } + let modValue = sum / modulus; + return (modValue - Math.floor(modValue)) === 0; +} +function mod10(number) { + return calculate(number, [2, 1], 10, (n) => n > 9 ? n - 9 : n); +} +exports.mod10 = mod10; +function mod11(number) { + return calculate(number, [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], 11); +} +exports.mod11 = mod11; +//# sourceMappingURL=mod10.js.map \ No newline at end of file diff --git a/dist/src/util/mod10.js.map b/dist/src/util/mod10.js.map new file mode 100644 index 0000000..d452522 --- /dev/null +++ b/dist/src/util/mod10.js.map @@ -0,0 +1 @@ +{"version":3,"file":"mod10.js","sourceRoot":"","sources":["../../../src/util/mod10.ts"],"names":[],"mappings":";;AAAA,SAAS,eAAe,CAAC,OAAiB,EAAE,MAAc;IACtD,IAAI,QAAQ,GAAG,OAAO,CAAA;IACtB,OAAO,QAAQ,CAAC,MAAM,GAAG,MAAM,EAAE;QAC7B,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;KACtC;IACD,OAAO,QAAQ,CAAC,MAAM,GAAG,MAAM,EAAE;QAC7B,QAAQ,CAAC,KAAK,EAAE,CAAA;KACnB;IAED,IAAI,QAAQ,CAAC,MAAM,KAAK,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAA;IACzD,OAAO,QAAQ,CAAA;AACnB,CAAC;AAED,SAAS,SAAS,CAAC,MAAc,EAAE,OAAiB,EAAE,OAAc,EAAE,cAAkB,CAAC,CAAK,EAAE,EAAE,CAAC,CAAC;IAChG,OAAO,GAAG,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;IAEjD,IAAI,GAAG,GAAU,CAAC,CAAA;IAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE;QACpC,GAAG,IAAI,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;KACvD;IAED,IAAI,QAAQ,GAAG,GAAG,GAAC,OAAO,CAAA;IAC1B,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAA;AAClD,CAAC;AAED,SAAgB,KAAK,CAAC,MAAa;IAC/B,OAAO,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,EAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAK,EAAE,EAAE,CAAC,CAAC,GAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAC,CAAC,CAAA,CAAC,CAAA,CAAC,CAAC,CAAA;AAC/D,CAAC;AAFD,sBAEC;AACD,SAAgB,KAAK,CAAC,MAAa;IAC/B,OAAO,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAC,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AACxD,CAAC;AAFD,sBAEC"} \ No newline at end of file diff --git a/dist/src/util/modulusCalculation.d.ts b/dist/src/util/modulusCalculation.d.ts new file mode 100644 index 0000000..f38829e --- /dev/null +++ b/dist/src/util/modulusCalculation.d.ts @@ -0,0 +1,2 @@ +export declare function calculate(number: string, weights: number[], postProcess?: any): number; +export declare function modulusValidation(sum: number, modulus: number): boolean; diff --git a/dist/src/util/modulusCalculation.js b/dist/src/util/modulusCalculation.js new file mode 100644 index 0000000..a6cc158 --- /dev/null +++ b/dist/src/util/modulusCalculation.js @@ -0,0 +1,27 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +function normaizeWeights(weights, length) { + let _weights = weights; + while (_weights.length < length) { + _weights = _weights.concat(weights); + } + while (_weights.length > length) { + _weights.shift(); + } + return _weights; +} +function calculate(number, weights, postProcess = (n) => n) { + weights = normaizeWeights(weights, number.length); + let sum = 0; + for (let i = 0; i < number.length; i++) { + sum += postProcess(parseInt(number[i]) * weights[i]); + } + return sum; +} +exports.calculate = calculate; +function modulusValidation(sum, modulus) { + let modValue = sum / modulus; + return (modValue - Math.floor(modValue)) === 0; +} +exports.modulusValidation = modulusValidation; +//# sourceMappingURL=modulusCalculation.js.map \ No newline at end of file diff --git a/dist/src/util/modulusCalculation.js.map b/dist/src/util/modulusCalculation.js.map new file mode 100644 index 0000000..ab3bd31 --- /dev/null +++ b/dist/src/util/modulusCalculation.js.map @@ -0,0 +1 @@ +{"version":3,"file":"modulusCalculation.js","sourceRoot":"","sources":["../../../src/util/modulusCalculation.ts"],"names":[],"mappings":";;AAAA,SAAS,eAAe,CAAC,OAAiB,EAAE,MAAc;IACtD,IAAI,QAAQ,GAAG,OAAO,CAAA;IACtB,OAAO,QAAQ,CAAC,MAAM,GAAG,MAAM,EAAE;QAC7B,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;KACtC;IACD,OAAO,QAAQ,CAAC,MAAM,GAAG,MAAM,EAAE;QAC7B,QAAQ,CAAC,KAAK,EAAE,CAAA;KACnB;IAED,OAAO,QAAQ,CAAA;AACnB,CAAC;AAED,SAAgB,SAAS,CAAC,MAAc,EAAE,OAAiB,EAAE,cAAkB,CAAC,CAAK,EAAE,EAAE,CAAC,CAAC;IACvF,OAAO,GAAG,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;IAEjD,IAAI,GAAG,GAAU,CAAC,CAAA;IAClB,KAAK,IAAI,CAAC,GAAU,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC3C,GAAG,IAAI,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;KACvD;IAED,OAAO,GAAG,CAAA;AACd,CAAC;AATD,8BASC;AAGD,SAAgB,iBAAiB,CAAC,GAAU,EAAE,OAAe;IACzD,IAAI,QAAQ,GAAG,GAAG,GAAG,OAAO,CAAA;IAC5B,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAA;AAClD,CAAC;AAHD,8CAGC"} \ No newline at end of file diff --git a/dist/src/util/standarizeInput.d.ts b/dist/src/util/standarizeInput.d.ts new file mode 100644 index 0000000..3e959d0 --- /dev/null +++ b/dist/src/util/standarizeInput.d.ts @@ -0,0 +1,2 @@ +import { ValidationInput } from "../types"; +export declare function standarizeInput(input: string | ValidationInput): ValidationInput; diff --git a/dist/src/util/standarizeInput.js b/dist/src/util/standarizeInput.js new file mode 100644 index 0000000..b05c4a4 --- /dev/null +++ b/dist/src/util/standarizeInput.js @@ -0,0 +1,23 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +// export function standarizeInput(input: string | ValidationInput):ValidationInput { +// let result:ValidationInput +// if (typeof input === "string") { +// result = { +// accountNumber: input +// } +// } else { +// result = input +// } +// return result +// } +function standarizeInput(input) { + if (typeof input === "string") { + input = { + accountNumber: input + }; + } + return input; +} +exports.standarizeInput = standarizeInput; +//# sourceMappingURL=standarizeInput.js.map \ No newline at end of file diff --git a/dist/src/util/standarizeInput.js.map b/dist/src/util/standarizeInput.js.map new file mode 100644 index 0000000..3468976 --- /dev/null +++ b/dist/src/util/standarizeInput.js.map @@ -0,0 +1 @@ +{"version":3,"file":"standarizeInput.js","sourceRoot":"","sources":["../../../src/util/standarizeInput.ts"],"names":[],"mappings":";;AAEA,qFAAqF;AACrF,iCAAiC;AACjC,uCAAuC;AACvC,qBAAqB;AACrB,mCAAmC;AACnC,YAAY;AACZ,eAAe;AACf,yBAAyB;AACzB,QAAQ;AACR,oBAAoB;AACpB,IAAI;AAEJ,SAAgB,eAAe,CAAC,KAA+B;IAC3D,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC3B,KAAK,GAAG;YACJ,aAAa,EAAE,KAAK;SACvB,CAAA;KACJ;IACD,OAAO,KAAK,CAAA;AAChB,CAAC;AAPD,0CAOC"} \ No newline at end of file diff --git a/dist/src/util/swedishBanks.d.ts b/dist/src/util/swedishBanks.d.ts new file mode 100644 index 0000000..295c8ae --- /dev/null +++ b/dist/src/util/swedishBanks.d.ts @@ -0,0 +1 @@ +export declare const swedishBanks: any[]; diff --git a/dist/src/util/swedishBanks.js b/dist/src/util/swedishBanks.js new file mode 100644 index 0000000..c5ae051 --- /dev/null +++ b/dist/src/util/swedishBanks.js @@ -0,0 +1,397 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.swedishBanks = [ + { + "bank": "Amfa Bank AB", + "clearingFrom": 9660, + "clearingTo": 9669, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Avanza Bank AB (deltar endast i dataclearingen, ej i bankgirosystemet)", + "clearingFrom": 9550, + "clearingTo": 9569, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "BlueStep Finans AB (deltar endast i dataclearingen, ej i Bankgirosystemet)", + "clearingFrom": 9680, + "clearingTo": 9689, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "BNP Paribas Fortis Bank", + "clearingFrom": 9470, + "clearingTo": 9479, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Citibank", + "clearingFrom": 9040, + "clearingTo": 9049, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Danske Bank", + "clearingFrom": 1200, + "clearingTo": 1399, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "Danske Bank", + "clearingFrom": 2400, + "clearingTo": 2499, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "DNB Bank", + "clearingFrom": 9190, + "clearingTo": 9199, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "DNB Bank", + "clearingFrom": 9260, + "clearingTo": 9269, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Ekobanken", + "clearingFrom": 9700, + "clearingTo": 9709, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Erik Penser AB (deltar endast i dataclearingen, ej i bankgirosystemet)", + "clearingFrom": 9590, + "clearingTo": 9599, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Forex Bank", + "clearingFrom": 9400, + "clearingTo": 9449, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "ICA Banken AB", + "clearingFrom": 9270, + "clearingTo": 9279, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "IKANO Bank", + "clearingFrom": 9170, + "clearingTo": 9179, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "JAK Medlemsbank (deltar endast i dataclearingen, ej i bankgirosystemet)", + "clearingFrom": 9670, + "clearingTo": 9679, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Landshypotek AB (deltar endast i dataclearingen, ej i bankgirosystemet)", + "clearingFrom": 9390, + "clearingTo": 9399, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "L%uFFFDn & Spar Bank Sverige (deltar endast i dataclearingen, ej i bankgirosystemet)", + "clearingFrom": 9630, + "clearingTo": 9639, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "L%uFFFDnsf%uFFFDrs%uFFFDkringar Bank", + "clearingFrom": 3400, + "clearingTo": 3409, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "L%uFFFDnsf%uFFFDrs%uFFFDkringar Bank", + "clearingFrom": 9020, + "clearingTo": 9029, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "L%uFFFDnsf%uFFFDrs%uFFFDkringar Bank", + "clearingFrom": 9060, + "clearingTo": 9069, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "Marginalen Bank", + "clearingFrom": 9230, + "clearingTo": 9239, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "Nordax Bank AB", + "clearingFrom": 9640, + "clearingTo": 9649, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Nordea", + "clearingFrom": 1100, + "clearingTo": 1199, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "Nordea", + "clearingFrom": 1400, + "clearingTo": 2099, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "Nordea (exkl. personkonton, cl 3300)", + "clearingFrom": 3000, + "clearingTo": 3399, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "Nordea (exkl. personkonton, cl 3782)", + "clearingFrom": 3410, + "clearingTo": 3999, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "Nordea", + "clearingFrom": 4000, + "clearingTo": 4999, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Nordnet Bank", + "clearingFrom": 9100, + "clearingTo": 9109, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Resurs Bank", + "clearingFrom": 9280, + "clearingTo": 9289, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "Riksg%uFFFDlden", + "clearingFrom": 9880, + "clearingTo": 9889, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Royal bank of Scotland", + "clearingFrom": 9090, + "clearingTo": 9099, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Santander Consumer Bank AS (deltar endast i dataclearingen, ej i bankgirosystemet)", + "clearingFrom": 9460, + "clearingTo": 9469, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "SBAB", + "clearingFrom": 9250, + "clearingTo": 9259, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "SEB", + "clearingFrom": 5000, + "clearingTo": 5999, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "SEB", + "clearingFrom": 9120, + "clearingTo": 9124, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "SEB", + "clearingFrom": 9130, + "clearingTo": 9149, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "Skandiabanken", + "clearingFrom": 9150, + "clearingTo": 9169, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Swedbank", + "clearingFrom": 7000, + "clearingTo": 7999, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "%uFFFDlandsbanken Sverige AB", + "clearingFrom": 2300, + "clearingTo": 2399, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Danske Bank", + "clearingFrom": 9180, + "clearingTo": 9189, + "format": "00xxxxxxxxxC", + "type": 2, + "comment": 1 + }, + { + "bank": "Handelsbanken", + "clearingFrom": 6000, + "clearingTo": 6999, + "format": "000xxxxxxxxC", + "type": 2, + "comment": 2 + }, + { + "bank": "Nordea/Plusgirot", + "clearingFrom": 9500, + "clearingTo": 9549, + "format": "00xxxxxxxxxC", + "type": 2, + "comment": 3 + }, + { + "bank": "Nordea/Plusgirot", + "clearingFrom": 9960, + "clearingTo": 9969, + "format": "00xxxxxxxxxC", + "type": 2, + "comment": 3 + }, + { + "bank": "Nordea - personkonto", + "clearingFrom": 3300, + "clearingTo": 3782, + "format": "00xxxxxxxxxC", + "type": 2, + "comment": 1 + }, + { + "bank": "Riksg%uFFFDlden", + "clearingFrom": 9890, + "clearingTo": 9899, + "format": "00xxxxxxxxxC", + "type": 2, + "comment": 1 + }, + { + "bank": "Sparbanken Syd", + "clearingFrom": 9570, + "clearingTo": 9579, + "format": "00xxxxxxxxxC", + "type": 2, + "comment": 1 + }, + { + "bank": "Swedbank", + "clearingFrom": 8000, + "clearingTo": 8999, + "format": "00xxxxxxxxxC", + "type": 2, + "comment": 3 + }, + { + "bank": "Swedbank (f.d. Sparbanken %uFFFDresund)", + "clearingFrom": 9300, + "clearingTo": 9329, + "format": "00xxxxxxxxxC", + "type": 2, + "comment": 1 + }, + { + "bank": "Swedbank (f.d. Sparbanken %uFFFDresund)", + "clearingFrom": 9330, + "clearingTo": 9349, + "format": "00xxxxxxxxxC", + "type": 2, + "comment": 1 + } +]; +//# sourceMappingURL=swedishBanks.js.map \ No newline at end of file diff --git a/dist/src/util/swedishBanks.js.map b/dist/src/util/swedishBanks.js.map new file mode 100644 index 0000000..1316e91 --- /dev/null +++ b/dist/src/util/swedishBanks.js.map @@ -0,0 +1 @@ +{"version":3,"file":"swedishBanks.js","sourceRoot":"","sources":["../../../src/util/swedishBanks.ts"],"names":[],"mappings":";;AAAa,QAAA,YAAY,GAAU;IACjC;QACE,MAAM,EAAE,cAAc;QACtB,cAAc,EAAE,IAAI;QACpB,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE,cAAc;QACxB,MAAM,EAAE,CAAC;QACT,SAAS,EAAE,CAAC;KACb;IACD;QACE,MAAM,EAAE,wEAAwE;QAChF,cAAc,EAAE,IAAI;QACpB,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE,cAAc;QACxB,MAAM,EAAE,CAAC;QACT,SAAS,EAAE,CAAC;KACb;IACD;QACE,MAAM,EAAE,4EAA4E;QACpF,cAAc,EAAE,IAAI;QACpB,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE,cAAc;QACxB,MAAM,EAAE,CAAC;QACT,SAAS,EAAE,CAAC;KACb;IACD;QACE,MAAM,EAAE,yBAAyB;QACjC,cAAc,EAAE,IAAI;QACpB,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE,cAAc;QACxB,MAAM,EAAE,CAAC;QACT,SAAS,EAAE,CAAC;KACb;IACD;QACE,MAAM,EAAE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,EAAE,iBAAiB;QACzB,cAAc,EAAE,IAAI;QACpB,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE,cAAc;QACxB,MAAM,EAAE,CAAC;QACT,SAAS,EAAE,CAAC;KACb;IACD;QACE,MAAM,EAAE,gBAAgB;QACxB,cAAc,EAAE,IAAI;QACpB,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE,cAAc;QACxB,MAAM,EAAE,CAAC;QACT,SAAS,EAAE,CAAC;KACb;IACD;QACE,MAAM,EAAE,UAAU;QAClB,cAAc,EAAE,IAAI;QACpB,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE,cAAc;QACxB,MAAM,EAAE,CAAC;QACT,SAAS,EAAE,CAAC;KACb;IACD;QACE,MAAM,EAAE,yCAAyC;QACjD,cAAc,EAAE,IAAI;QACpB,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE,cAAc;QACxB,MAAM,EAAE,CAAC;QACT,SAAS,EAAE,CAAC;KACb;IACD;QACE,MAAM,EAAE,yCAAyC;QACjD,cAAc,EAAE,IAAI;QACpB,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE,cAAc;QACxB,MAAM,EAAE,CAAC;QACT,SAAS,EAAE,CAAC;KACb;CACF,CAAA"} \ No newline at end of file diff --git a/dist/src/validators/IbanValidation.d.ts b/dist/src/validators/IbanValidation.d.ts new file mode 100644 index 0000000..2173364 --- /dev/null +++ b/dist/src/validators/IbanValidation.d.ts @@ -0,0 +1,11 @@ +import * as types from "../types"; +import { IValidation, ValidationInput } from "../types"; +export declare class IbanValidation implements IValidation { + _config: types.BankAccountValidationConfig; + private _syntaxTester; + constructor(config: Partial); + canValidate(input: string | ValidationInput): Boolean; + validate(input: string | ValidationInput): { + valid: boolean; + }; +} diff --git a/dist/src/validators/IbanValidation.js b/dist/src/validators/IbanValidation.js new file mode 100644 index 0000000..004eb09 --- /dev/null +++ b/dist/src/validators/IbanValidation.js @@ -0,0 +1,25 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const defaultsDeep = require("lodash.defaultsdeep"); +const defaultConfig_1 = require("../defaultConfig"); +const standarizeInput_1 = require("../util/standarizeInput"); +const ibantools = require("ibantools"); +class IbanValidation { + constructor(config) { + this._config = defaultsDeep({}, config, defaultConfig_1.default); + this._syntaxTester = /^[A-Z]{2}\d{2}.*$/; + } + canValidate(input) { + input = standarizeInput_1.standarizeInput(input); + return (!input.type || input.type === 'iban') + && this._syntaxTester.test(input.accountNumber); + } + validate(input) { + input = standarizeInput_1.standarizeInput(input); + return { + valid: ibantools.isValidIBAN(input.accountNumber) + }; + } +} +exports.IbanValidation = IbanValidation; +//# sourceMappingURL=IbanValidation.js.map \ No newline at end of file diff --git a/dist/src/validators/IbanValidation.js.map b/dist/src/validators/IbanValidation.js.map new file mode 100644 index 0000000..059df2a --- /dev/null +++ b/dist/src/validators/IbanValidation.js.map @@ -0,0 +1 @@ +{"version":3,"file":"IbanValidation.js","sourceRoot":"","sources":["../../../src/validators/IbanValidation.ts"],"names":[],"mappings":";;AAAA,oDAAoD;AAGpD,oDAA4C;AAC5C,6DAAuD;AACvD,uCAAsC;AAEtC,MAAa,cAAc;IAIvB,YAAY,MAAkD;QAC1D,IAAI,CAAC,OAAO,GAAG,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,uBAAa,CAAC,CAAA;QACtD,IAAI,CAAC,aAAa,GAAG,mBAAmB,CAAA;IAC5C,CAAC;IAED,WAAW,CAAC,KAA+B;QACvC,KAAK,GAAG,iCAAe,CAAC,KAAK,CAAC,CAAA;QAE9B,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC;eACtC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;IACvD,CAAC;IAED,QAAQ,CAAC,KAA+B;QACpC,KAAK,GAAG,iCAAe,CAAC,KAAK,CAAC,CAAA;QAE9B,OAAO;YACH,KAAK,EAAE,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,aAAa,CAAC;SACpD,CAAA;IACL,CAAC;CACJ;AAvBD,wCAuBC"} \ No newline at end of file diff --git a/dist/src/validators/NorwegianBbanValidation.d.ts b/dist/src/validators/NorwegianBbanValidation.d.ts new file mode 100644 index 0000000..36e2b5e --- /dev/null +++ b/dist/src/validators/NorwegianBbanValidation.d.ts @@ -0,0 +1,11 @@ +import * as types from "../types"; +import { IValidation, ValidationInput } from "../types"; +export declare class NorwegianBbanValidation implements IValidation { + _config: types.BankAccountValidationConfig; + private _syntaxTester; + constructor(config: Partial); + canValidate(input: string | ValidationInput): Boolean; + validate(input: string | ValidationInput): { + valid: boolean; + }; +} diff --git a/dist/src/validators/NorwegianBbanValidation.js b/dist/src/validators/NorwegianBbanValidation.js new file mode 100644 index 0000000..72c4b2d --- /dev/null +++ b/dist/src/validators/NorwegianBbanValidation.js @@ -0,0 +1,31 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const defaultsDeep = require("lodash.defaultsdeep"); +const defaultConfig_1 = require("../defaultConfig"); +const standarizeInput_1 = require("../util/standarizeInput"); +// import * as checkdigit from 'checkdigit' +const modulusCalculation_1 = require("../util/modulusCalculation"); +class NorwegianBbanValidation { + constructor(config) { + this._config = defaultsDeep({}, config, defaultConfig_1.default); + this._syntaxTester = /^\d{11}$/; + } + canValidate(input) { + input = standarizeInput_1.standarizeInput(input); + return (!input.type || input.type === 'bban') + && input.countryCode === 'NO'; + } + validate(input) { + input = standarizeInput_1.standarizeInput(input); + return { + valid: this._syntaxTester.test(input.accountNumber) && + norMod11(input.accountNumber) + }; + } +} +exports.NorwegianBbanValidation = NorwegianBbanValidation; +function norMod11(number) { + let sum = modulusCalculation_1.calculate(number, [5, 4, 3, 2, 7, 6, 5, 4, 3, 2, 1]); + return modulusCalculation_1.modulusValidation(sum, 11); +} +//# sourceMappingURL=NorwegianBbanValidation.js.map \ No newline at end of file diff --git a/dist/src/validators/NorwegianBbanValidation.js.map b/dist/src/validators/NorwegianBbanValidation.js.map new file mode 100644 index 0000000..de5a5ff --- /dev/null +++ b/dist/src/validators/NorwegianBbanValidation.js.map @@ -0,0 +1 @@ +{"version":3,"file":"NorwegianBbanValidation.js","sourceRoot":"","sources":["../../../src/validators/NorwegianBbanValidation.ts"],"names":[],"mappings":";;AAAA,oDAAoD;AAGpD,oDAA4C;AAC5C,6DAAuD;AACvD,2CAA2C;AAC3C,mEAAuE;AAEvE,MAAa,uBAAuB;IAIhC,YAAY,MAAkD;QAC1D,IAAI,CAAC,OAAO,GAAG,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,uBAAa,CAAC,CAAA;QACtD,IAAI,CAAC,aAAa,GAAG,UAAU,CAAA;IACnC,CAAC;IAED,WAAW,CAAC,KAA+B;QACvC,KAAK,GAAG,iCAAe,CAAC,KAAK,CAAC,CAAA;QAE9B,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC;eACtC,KAAK,CAAC,WAAW,KAAK,IAAI,CAAA;IACrC,CAAC;IAED,QAAQ,CAAC,KAA+B;QACpC,KAAK,GAAG,iCAAe,CAAC,KAAK,CAAC,CAAA;QAE9B,OAAO;YACH,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC;gBAC/C,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC;SACpC,CAAA;IACL,CAAC;CACJ;AAxBD,0DAwBC;AACD,SAAS,QAAQ,CAAC,MAAa;IAC3B,IAAI,GAAG,GAAG,8BAAS,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IAC9D,OAAO,sCAAiB,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;AACrC,CAAC"} \ No newline at end of file diff --git a/dist/src/validators/SwedishBankgiroValidation.d.ts b/dist/src/validators/SwedishBankgiroValidation.d.ts new file mode 100644 index 0000000..12a6088 --- /dev/null +++ b/dist/src/validators/SwedishBankgiroValidation.d.ts @@ -0,0 +1,11 @@ +import * as types from "../types"; +import { IValidation, ValidationInput } from "../types"; +export declare class SwedishBankgiroValidation implements IValidation { + _config: types.BankAccountValidationConfig; + private _syntaxTester; + constructor(config: Partial); + canValidate(input: string | ValidationInput): Boolean; + validate(input: string | ValidationInput): { + valid: boolean; + }; +} diff --git a/dist/src/validators/SwedishBankgiroValidation.js b/dist/src/validators/SwedishBankgiroValidation.js new file mode 100644 index 0000000..f5f9cce --- /dev/null +++ b/dist/src/validators/SwedishBankgiroValidation.js @@ -0,0 +1,24 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const defaultsDeep = require("lodash.defaultsdeep"); +const defaultConfig_1 = require("../defaultConfig"); +const standarizeInput_1 = require("../util/standarizeInput"); +class SwedishBankgiroValidation { + constructor(config) { + this._config = defaultsDeep({}, config, defaultConfig_1.default); + this._syntaxTester = /^\d{3,4}-\d{4}$/; + } + canValidate(input) { + input = standarizeInput_1.standarizeInput(input); + return (!input.type || input.type === 'bankgiro') + && input.countryCode === 'SE'; + } + validate(input) { + input = standarizeInput_1.standarizeInput(input); + return { + valid: this._syntaxTester.test(input.accountNumber) + }; + } +} +exports.SwedishBankgiroValidation = SwedishBankgiroValidation; +//# sourceMappingURL=SwedishBankgiroValidation.js.map \ No newline at end of file diff --git a/dist/src/validators/SwedishBankgiroValidation.js.map b/dist/src/validators/SwedishBankgiroValidation.js.map new file mode 100644 index 0000000..8909494 --- /dev/null +++ b/dist/src/validators/SwedishBankgiroValidation.js.map @@ -0,0 +1 @@ +{"version":3,"file":"SwedishBankgiroValidation.js","sourceRoot":"","sources":["../../../src/validators/SwedishBankgiroValidation.ts"],"names":[],"mappings":";;AAAA,oDAAoD;AAGpD,oDAA4C;AAC5C,6DAAuD;AAEvD,MAAa,yBAAyB;IAIlC,YAAY,MAAkD;QAC1D,IAAI,CAAC,OAAO,GAAG,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,uBAAa,CAAC,CAAA;QACtD,IAAI,CAAC,aAAa,GAAG,iBAAiB,CAAA;IAC1C,CAAC;IAED,WAAW,CAAC,KAA+B;QACvC,KAAK,GAAG,iCAAe,CAAC,KAAK,CAAC,CAAA;QAE9B,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,CAAC;eAC1C,KAAK,CAAC,WAAW,KAAK,IAAI,CAAA;IACrC,CAAC;IAED,QAAQ,CAAC,KAA+B;QACpC,KAAK,GAAG,iCAAe,CAAC,KAAK,CAAC,CAAA;QAE9B,OAAO;YACH,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC;SACtD,CAAA;IACL,CAAC;CACJ;AAvBD,8DAuBC"} \ No newline at end of file diff --git a/dist/src/validators/SwedishBbanValidation.d.ts b/dist/src/validators/SwedishBbanValidation.d.ts new file mode 100644 index 0000000..bca8e41 --- /dev/null +++ b/dist/src/validators/SwedishBbanValidation.d.ts @@ -0,0 +1,13 @@ +import * as types from "../types"; +import { IValidation, ValidationInput } from "../types"; +export declare class SwedishBbanValidation implements IValidation { + _config: types.BankAccountValidationConfig; + private _syntaxTester; + constructor(config: Partial); + canValidate(input: string | ValidationInput): Boolean; + validate(input: string | ValidationInput): { + valid: boolean; + }; + private parseBban; + private getType; +} diff --git a/dist/src/validators/SwedishBbanValidation.js b/dist/src/validators/SwedishBbanValidation.js new file mode 100644 index 0000000..a0b459a --- /dev/null +++ b/dist/src/validators/SwedishBbanValidation.js @@ -0,0 +1,68 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const defaultsDeep = require("lodash.defaultsdeep"); +const defaultConfig_1 = require("../defaultConfig"); +const swedishBanks_1 = require("../util/swedishBanks"); +const standarizeInput_1 = require("../util/standarizeInput"); +const modulusCalculation_1 = require("../util/modulusCalculation"); +class SwedishBbanValidation { + constructor(config) { + this._config = defaultsDeep({}, config, defaultConfig_1.default); + /* syntax: clearing (4 digit) + account number (7, 9 or 10 digit) */ + this._syntaxTester = /^\d{4}(:?\d{7}|\d{9}|\d{10})$/; + } + canValidate(input) { + input = standarizeInput_1.standarizeInput(input); + return (!input.type || input.type === 'bban') + && input.countryCode === 'SE'; + } + validate(input) { + input = standarizeInput_1.standarizeInput(input); + let bban = input.accountNumber; + let valid = this._syntaxTester.test(bban); + if (!valid) { + return { valid: false }; + } + let account = this.parseBban(bban); + if (account.type === '1.1' && account.length === 7 && sweMod11(account.bban.substr(1)) || + account.type === '1.2' && account.length === 7 && sweMod11(account.bban) || + account.type === '2.1' && account.length === 10 && sweMod10(account.accountNumber) || + account.type === '2.2' && account.length === 9 && sweMod11(account.accountNumber) || + account.type === '2.3' && account.length === 10 && sweMod10(account.accountNumber)) { + return { valid: true }; + } + return { valid: false }; + } + parseBban(bban) { + let clearing = parseInt(bban.substr(0, 4)); + let accountNumber = bban.substr(4); + let type = this.getType(clearing); + return { + clearing, + accountNumber, + bban, + type, + length: accountNumber.length + }; + } + getType(clearingNumber) { + let banks = swedishBanks_1.swedishBanks.filter(bank => { + return bank.clearingFrom <= clearingNumber && clearingNumber <= bank.clearingTo; + }); + if (banks.length !== 1) { + return '0.0'; + } + let bank = banks[0]; + return bank.type + '.' + bank.comment; + } +} +exports.SwedishBbanValidation = SwedishBbanValidation; +function sweMod10(number) { + let sum = modulusCalculation_1.calculate(number, [2, 1], (n) => n > 9 ? n - 9 : n); + return modulusCalculation_1.modulusValidation(sum, 10); +} +function sweMod11(number) { + let sum = modulusCalculation_1.calculate(number, [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); + return modulusCalculation_1.modulusValidation(sum, 11); +} +//# sourceMappingURL=SwedishBbanValidation.js.map \ No newline at end of file diff --git a/dist/src/validators/SwedishBbanValidation.js.map b/dist/src/validators/SwedishBbanValidation.js.map new file mode 100644 index 0000000..555d1a6 --- /dev/null +++ b/dist/src/validators/SwedishBbanValidation.js.map @@ -0,0 +1 @@ +{"version":3,"file":"SwedishBbanValidation.js","sourceRoot":"","sources":["../../../src/validators/SwedishBbanValidation.ts"],"names":[],"mappings":";;AAAA,oDAAoD;AAGpD,oDAA4C;AAC5C,uDAAiD;AACjD,6DAAuD;AACvD,mEAAuE;AAUvE,MAAa,qBAAqB;IAI9B,YAAY,MAAkD;QAC1D,IAAI,CAAC,OAAO,GAAG,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,uBAAa,CAAC,CAAA;QACtD,oEAAoE;QACpE,IAAI,CAAC,aAAa,GAAG,+BAA+B,CAAA;IACxD,CAAC;IAED,WAAW,CAAC,KAA+B;QACvC,KAAK,GAAG,iCAAe,CAAC,KAAK,CAAC,CAAA;QAE9B,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC;eACtC,KAAK,CAAC,WAAW,KAAK,IAAI,CAAA;IACrC,CAAC;IAED,QAAQ,CAAC,KAA+B;QACpC,KAAK,GAAG,iCAAe,CAAC,KAAK,CAAC,CAAA;QAC9B,IAAI,IAAI,GAAG,KAAK,CAAC,aAAa,CAAA;QAE9B,IAAI,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAEzC,IAAI,CAAC,KAAK,EAAC;YACP,OAAO,EAAC,KAAK,EAAC,KAAK,EAAC,CAAA;SACvB;QAED,IAAI,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;QAElC,IACI,OAAO,CAAC,IAAI,KAAK,KAAK,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAK,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YACnF,OAAO,CAAC,IAAI,KAAK,KAAK,IAAI,OAAO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,CAAA;QAEnB,OAAO,IAAI,CAAC,IAAI,GAAG,GAAG,GAAG,IAAI,CAAC,OAAO,CAAA;IACzC,CAAC;CACJ;AArED,sDAqEC;AAGD,SAAS,QAAQ,CAAC,MAAa;IAC3B,IAAI,GAAG,GAAG,8BAAS,CAAC,MAAM,EAAE,CAAC,CAAC,EAAC,CAAC,CAAC,EAAE,CAAC,CAAK,EAAE,EAAE,CAAC,CAAC,GAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAC,CAAC,CAAA,CAAC,CAAA,CAAC,CAAC,CAAA;IAC1D,OAAO,sCAAiB,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;AACrC,CAAC;AAED,SAAS,QAAQ,CAAC,MAAa;IAC3B,IAAI,GAAG,GAAG,8BAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAC,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAA;IACnD,OAAO,sCAAiB,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;AACrC,CAAC"} \ No newline at end of file diff --git a/dist/src/validators/SwedishPlusgiroValidation.d.ts b/dist/src/validators/SwedishPlusgiroValidation.d.ts new file mode 100644 index 0000000..a31fec4 --- /dev/null +++ b/dist/src/validators/SwedishPlusgiroValidation.d.ts @@ -0,0 +1,11 @@ +import * as types from "../types"; +import { IValidation, ValidationInput } from "../types"; +export declare class SwedishPlusgiroValidation implements IValidation { + _config: types.BankAccountValidationConfig; + private _syntaxTester; + constructor(config: Partial); + canValidate(input: string | ValidationInput): Boolean; + validate(input: string | ValidationInput): { + valid: boolean; + }; +} diff --git a/dist/src/validators/SwedishPlusgiroValidation.js b/dist/src/validators/SwedishPlusgiroValidation.js new file mode 100644 index 0000000..b1940bc --- /dev/null +++ b/dist/src/validators/SwedishPlusgiroValidation.js @@ -0,0 +1,24 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const defaultsDeep = require("lodash.defaultsdeep"); +const defaultConfig_1 = require("../defaultConfig"); +const standarizeInput_1 = require("../util/standarizeInput"); +class SwedishPlusgiroValidation { + constructor(config) { + this._config = defaultsDeep({}, config, defaultConfig_1.default); + this._syntaxTester = /^(\d{1,7})-\d$/; + } + canValidate(input) { + input = standarizeInput_1.standarizeInput(input); + return (!input.type || input.type === 'plusgiro') + && input.countryCode === 'SE'; + } + validate(input) { + input = standarizeInput_1.standarizeInput(input); + return { + valid: this._syntaxTester.test(input.accountNumber) + }; + } +} +exports.SwedishPlusgiroValidation = SwedishPlusgiroValidation; +//# sourceMappingURL=SwedishPlusgiroValidation.js.map \ No newline at end of file diff --git a/dist/src/validators/SwedishPlusgiroValidation.js.map b/dist/src/validators/SwedishPlusgiroValidation.js.map new file mode 100644 index 0000000..185069d --- /dev/null +++ b/dist/src/validators/SwedishPlusgiroValidation.js.map @@ -0,0 +1 @@ +{"version":3,"file":"SwedishPlusgiroValidation.js","sourceRoot":"","sources":["../../../src/validators/SwedishPlusgiroValidation.ts"],"names":[],"mappings":";;AAAA,oDAAoD;AAGpD,oDAA4C;AAC5C,6DAAuD;AAEvD,MAAa,yBAAyB;IAIlC,YAAY,MAAkD;QAC1D,IAAI,CAAC,OAAO,GAAG,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,uBAAa,CAAC,CAAA;QACtD,IAAI,CAAC,aAAa,GAAG,gBAAgB,CAAA;IACzC,CAAC;IAED,WAAW,CAAC,KAA+B;QACvC,KAAK,GAAG,iCAAe,CAAC,KAAK,CAAC,CAAA;QAE9B,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,CAAC;eAC1C,KAAK,CAAC,WAAW,KAAK,IAAI,CAAA;IACrC,CAAC;IAED,QAAQ,CAAC,KAA+B;QACpC,KAAK,GAAG,iCAAe,CAAC,KAAK,CAAC,CAAA;QAE9B,OAAO;YACH,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC;SACtD,CAAA;IACL,CAAC;CACJ;AAvBD,8DAuBC"} \ No newline at end of file diff --git a/dist/test/NO/testBbanValidation.d.ts b/dist/test/NO/testBbanValidation.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/dist/test/NO/testBbanValidation.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/dist/test/NO/testBbanValidation.js b/dist/test/NO/testBbanValidation.js new file mode 100644 index 0000000..77bba9b --- /dev/null +++ b/dist/test/NO/testBbanValidation.js @@ -0,0 +1,48 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const chai = require("chai"); +const NorwegianBbanValidation_1 = require("../../src/validators/NorwegianBbanValidation"); +// 11110077949 +// 22220012607 +// 33330027946 +// 44440025746 +// 55550090405 +// 66660052292 +// 77770076598 +// 88880051606 +// 99990043120 +describe('NorwegianBbanValidation', () => { + let validation; + beforeEach(() => { + validation = new NorwegianBbanValidation_1.NorwegianBbanValidation({}); + }); + describe('when validating', () => { + it('should validate a valid Norwegian BBAN account as string input', () => { + chai.expect(validation.validate('11110077949')).to.deep.equal({ + 'valid': true + }); + }); + it('should validate a valid Norwegian BBAN account as object input', () => { + chai.expect(validation.validate({ accountNumber: '11110077949' })).to.deep.equal({ + 'valid': true + }); + }); + it('should invalidate an invalid Norwegian BBAN account', () => { + chai.expect(validation.validate('11110077948')).to.deep.equal({ + 'valid': false + }); + }); + }); + describe('when determining suitability', () => { + it('should accept a norwegian country', () => { + chai.expect(validation.canValidate({ accountNumber: 'invalid', countryCode: 'NO' })).to.equal(true); + }); + it('should not accept a swedish country', () => { + chai.expect(validation.canValidate({ accountNumber: 'invalid', countryCode: 'SE' })).to.equal(false); + }); + it('should not accept a type different from bban', () => { + chai.expect(validation.canValidate({ accountNumber: 'invalid', countryCode: 'NO', type: 'iban' })).to.equal(false); + }); + }); +}); +//# sourceMappingURL=testBbanValidation.js.map \ No newline at end of file diff --git a/dist/test/NO/testBbanValidation.js.map b/dist/test/NO/testBbanValidation.js.map new file mode 100644 index 0000000..923949a --- /dev/null +++ b/dist/test/NO/testBbanValidation.js.map @@ -0,0 +1 @@ +{"version":3,"file":"testBbanValidation.js","sourceRoot":"","sources":["../../../test/NO/testBbanValidation.ts"],"names":[],"mappings":";;AAAA,6BAA4B;AAC5B,0FAAoF;AAEpF,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,QAAQ,CAAC,yBAAyB,EAAE,GAAE,EAAE;IACpC,IAAI,UAAkC,CAAA;IACtC,UAAU,CAAC,GAAE,EAAE;QACX,UAAU,GAAG,IAAI,iDAAuB,CAAC,EAAE,CAAC,CAAA;IAChD,CAAC,CAAC,CAAA;IAEF,QAAQ,CAAC,iBAAiB,EAAE,GAAE,EAAE;QAC5B,EAAE,CAAC,gEAAgE,EAAE,GAAE,EAAE;YACrE,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;gBAC1D,OAAO,EAAE,IAAI;aAChB,CAAC,CAAA;QACN,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,gEAAgE,EAAE,GAAE,EAAE;YACrE,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAC,aAAa,EAAE,aAAa,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;gBAC3E,OAAO,EAAE,IAAI;aAChB,CAAC,CAAA;QACN,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,qDAAqD,EAAE,GAAE,EAAE;YAC1D,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;gBAC1D,OAAO,EAAE,KAAK;aACjB,CAAC,CAAA;QACN,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;IAEF,QAAQ,CAAC,8BAA8B,EAAE,GAAE,EAAE;QACzC,EAAE,CAAC,mCAAmC,EAAE,GAAE,EAAE;YACxC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,EAAC,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACrG,CAAC,CAAC,CAAA;QACF,EAAE,CAAC,qCAAqC,EAAE,GAAE,EAAE;YAC1C,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,EAAC,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACtG,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,8CAA8C,EAAE,GAAE,EAAE;YACnD,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,EAAC,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACpH,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/test/SE/testBbanValidation.d.ts b/dist/test/SE/testBbanValidation.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/dist/test/SE/testBbanValidation.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/dist/test/SE/testBbanValidation.js b/dist/test/SE/testBbanValidation.js new file mode 100644 index 0000000..7164913 --- /dev/null +++ b/dist/test/SE/testBbanValidation.js @@ -0,0 +1,34 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const chai = require("chai"); +const SwedishBbanValidation_1 = require("../../src/validators/SwedishBbanValidation"); +describe('SwedishBbanValidation', () => { + let validation; + beforeEach(() => { + validation = new SwedishBbanValidation_1.SwedishBbanValidation({}); + }); + describe('when validating', () => { + it('should invalidate an unknown clearing number in a Swedish BBAN account (type 0.0)', () => { + chai.expect(validation.validate({ accountNumber: '90307777777' })).to.deep.equal({ + 'valid': false + }); + }); + it('should invalidate a Swedish BBAN account with invalid syntax', () => { + chai.expect(validation.validate({ accountNumber: '544088888888' })).to.deep.equal({ + 'valid': false + }); + }); + }); + describe('when determining suitability', () => { + it('should accept a Swedish country', () => { + chai.expect(validation.canValidate({ accountNumber: 'invalid', countryCode: 'SE' })).to.equal(true); + }); + it('should not accept a norwegian country', () => { + chai.expect(validation.canValidate({ accountNumber: 'invalid', countryCode: 'NO' })).to.equal(false); + }); + it('should not accept a type different from bban', () => { + chai.expect(validation.canValidate({ accountNumber: 'invalid', countryCode: 'SE', type: 'iban' })).to.equal(false); + }); + }); +}); +//# sourceMappingURL=testBbanValidation.js.map \ No newline at end of file diff --git a/dist/test/SE/testBbanValidation.js.map b/dist/test/SE/testBbanValidation.js.map new file mode 100644 index 0000000..28e8a8b --- /dev/null +++ b/dist/test/SE/testBbanValidation.js.map @@ -0,0 +1 @@ +{"version":3,"file":"testBbanValidation.js","sourceRoot":"","sources":["../../../test/SE/testBbanValidation.ts"],"names":[],"mappings":";;AAAA,6BAA4B;AAC5B,sFAAgF;AAEhF,QAAQ,CAAC,uBAAuB,EAAE,GAAE,EAAE;IAClC,IAAI,UAAgC,CAAA;IACpC,UAAU,CAAC,GAAE,EAAE;QACX,UAAU,GAAG,IAAI,6CAAqB,CAAC,EAAE,CAAC,CAAA;IAC9C,CAAC,CAAC,CAAA;IAEF,QAAQ,CAAC,iBAAiB,EAAE,GAAE,EAAE;QAG5B,EAAE,CAAC,mFAAmF,EAAE,GAAE,EAAE;YACxF,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAC,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C,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/test/SE/testSwedishBankgiroValidation.d.ts b/dist/test/SE/testSwedishBankgiroValidation.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/dist/test/SE/testSwedishBankgiroValidation.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/dist/test/SE/testSwedishBankgiroValidation.js b/dist/test/SE/testSwedishBankgiroValidation.js new file mode 100644 index 0000000..d2002db --- /dev/null +++ b/dist/test/SE/testSwedishBankgiroValidation.js @@ -0,0 +1,39 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const chai = require("chai"); +const SwedishBankgiroValidation_1 = require("../../src/validators/SwedishBankgiroValidation"); +describe('SwedishBankgiroValidation', () => { + let validation; + beforeEach(() => { + validation = new SwedishBankgiroValidation_1.SwedishBankgiroValidation({}); + }); + describe('when validating', () => { + it('should validate a valid bankgiro account number as string input', () => { + chai.expect(validation.validate('1234-1234')).to.deep.equal({ + 'valid': true + }); + }); + it('should validate a valid bankgiro account number as object input', () => { + chai.expect(validation.validate({ accountNumber: '123-1234' })).to.deep.equal({ + 'valid': true + }); + }); + it('should invalidate an invalid bankgiro account number', () => { + chai.expect(validation.validate('12345-1234')).to.deep.equal({ + 'valid': false + }); + }); + }); + describe('when determining suitability', () => { + it('should accept a swedish country', () => { + chai.expect(validation.canValidate({ accountNumber: 'invalid', countryCode: 'SE' })).to.equal(true); + }); + it('should not accept a norwegian country', () => { + chai.expect(validation.canValidate({ accountNumber: 'invalid', countryCode: 'NO' })).to.equal(false); + }); + it('should not accept a type different from bankgiro', () => { + chai.expect(validation.canValidate({ accountNumber: 'invalid', countryCode: 'SE', type: 'bban' })).to.equal(false); + }); + }); +}); +//# sourceMappingURL=testSwedishBankgiroValidation.js.map \ No newline at end of file diff --git a/dist/test/SE/testSwedishBankgiroValidation.js.map b/dist/test/SE/testSwedishBankgiroValidation.js.map new file mode 100644 index 0000000..74343be --- /dev/null +++ b/dist/test/SE/testSwedishBankgiroValidation.js.map @@ -0,0 +1 @@ +{"version":3,"file":"testSwedishBankgiroValidation.js","sourceRoot":"","sources":["../../../test/SE/testSwedishBankgiroValidation.ts"],"names":[],"mappings":";;AAAA,6BAA4B;AAC5B,8FAAwF;AAExF,QAAQ,CAAC,2BAA2B,EAAE,GAAE,EAAE;IACtC,IAAI,UAAoC,CAAA;IACxC,UAAU,CAAC,GAAE,EAAE;QACX,UAAU,GAAG,IAAI,qDAAyB,CAAC,EAAE,CAAC,CAAA;IAClD,CAAC,CAAC,CAAA;IAEF,QAAQ,CAAC,iBAAiB,EAAE,GAAE,EAAE;QAC5B,EAAE,CAAC,iEAAiE,EAAE,GAAE,EAAE;YACtE,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;gBACxD,OAAO,EAAE,IAAI;aAChB,CAAC,CAAA;QACN,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,iEAAiE,EAAE,GAAE,EAAE;YACtE,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAC,aAAa,EAAE,UAAU,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;gBACxE,OAAO,EAAE,IAAI;aAChB,CAAC,CAAA;QACN,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,sDAAsD,EAAE,GAAE,EAAE;YAC3D,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;gBACzD,OAAO,EAAE,KAAK;aACjB,CAAC,CAAA;QACN,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;IAEF,QAAQ,CAAC,8BAA8B,EAAE,GAAE,EAAE;QACzC,EAAE,CAAC,iCAAiC,EAAE,GAAE,EAAE;YACtC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,EAAC,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACrG,CAAC,CAAC,CAAA;QACF,EAAE,CAAC,uCAAuC,EAAE,GAAE,EAAE;YAC5C,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,EAAC,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACtG,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,kDAAkD,EAAE,GAAE,EAAE;YACvD,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,EAAC,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACpH,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/test/SE/testSwedishPlusgiroValidation.d.ts b/dist/test/SE/testSwedishPlusgiroValidation.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/dist/test/SE/testSwedishPlusgiroValidation.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/dist/test/SE/testSwedishPlusgiroValidation.js b/dist/test/SE/testSwedishPlusgiroValidation.js new file mode 100644 index 0000000..ddfa655 --- /dev/null +++ b/dist/test/SE/testSwedishPlusgiroValidation.js @@ -0,0 +1,74 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const chai = require("chai"); +const SwedishPlusgiroValidation_1 = require("../../src/validators/SwedishPlusgiroValidation"); +describe('SwedishPlusgiroValidation', () => { + let validation; + beforeEach(() => { + validation = new SwedishPlusgiroValidation_1.SwedishPlusgiroValidation({}); + }); + describe('when validating', () => { + it('should validate a valid plusgiro account number as string input', () => { + chai.expect(validation.validate('12345-1')).to.deep.equal({ + 'valid': true + }); + }); + it('should validate a plusgiro account number with format X-Y', () => { + chai.expect(validation.validate('1-1')).to.deep.equal({ + 'valid': true + }); + }); + it('should validate a plusgiro account number with format XX-Y', () => { + chai.expect(validation.validate('22-1')).to.deep.equal({ + 'valid': true + }); + }); + it('should validate a plusgiro account number with format XXX-Y', () => { + chai.expect(validation.validate('333-1')).to.deep.equal({ + 'valid': true + }); + }); + it('should validate a plusgiro account number with format XXXX-Y', () => { + chai.expect(validation.validate('4444-1')).to.deep.equal({ + 'valid': true + }); + }); + it('should validate a plusgiro account number with format XXXXX-Y', () => { + chai.expect(validation.validate('55555-1')).to.deep.equal({ + 'valid': true + }); + }); + it('should validate a plusgiro account number with format XXXXXX-Y', () => { + chai.expect(validation.validate('666666-1')).to.deep.equal({ + 'valid': true + }); + }); + it('should validate a plusgiro account number with format XXXXXXX-Y', () => { + chai.expect(validation.validate('7777777-1')).to.deep.equal({ + 'valid': true + }); + }); + it('should validate a valid plusgiro account number as object input', () => { + chai.expect(validation.validate({ accountNumber: '1234567-1' })).to.deep.equal({ + 'valid': true + }); + }); + it('should invalidate an invalid plusgiro account number', () => { + chai.expect(validation.validate('12345678-1')).to.deep.equal({ + 'valid': false + }); + }); + }); + describe('when determining suitability', () => { + it('should accept a swedish country', () => { + chai.expect(validation.canValidate({ accountNumber: 'invalid', countryCode: 'SE' })).to.equal(true); + }); + it('should not accept a norwegian country', () => { + chai.expect(validation.canValidate({ accountNumber: 'invalid', countryCode: 'NO' })).to.equal(false); + }); + it('should not accept a type different from plusgiro', () => { + chai.expect(validation.canValidate({ accountNumber: 'invalid', countryCode: 'SE', type: 'bban' })).to.equal(false); + }); + }); +}); +//# sourceMappingURL=testSwedishPlusgiroValidation.js.map \ No newline at end of file diff --git a/dist/test/SE/testSwedishPlusgiroValidation.js.map b/dist/test/SE/testSwedishPlusgiroValidation.js.map new file mode 100644 index 0000000..8b287a4 --- /dev/null +++ b/dist/test/SE/testSwedishPlusgiroValidation.js.map @@ -0,0 +1 @@ +{"version":3,"file":"testSwedishPlusgiroValidation.js","sourceRoot":"","sources":["../../../test/SE/testSwedishPlusgiroValidation.ts"],"names":[],"mappings":";;AAAA,6BAA4B;AAC5B,8FAAwF;AAExF,QAAQ,CAAC,2BAA2B,EAAE,GAAE,EAAE;IACtC,IAAI,UAAoC,CAAA;IACxC,UAAU,CAAC,GAAE,EAAE;QACX,UAAU,GAAG,IAAI,qDAAyB,CAAC,EAAE,CAAC,CAAA;IAClD,CAAC,CAAC,CAAA;IAEF,QAAQ,CAAC,iBAAiB,EAAE,GAAE,EAAE;QAC5B,EAAE,CAAC,iEAAiE,EAAE,GAAE,EAAE;YACtE,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;gBACtD,OAAO,EAAE,IAAI;aAChB,CAAC,CAAA;QACN,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,2DAA2D,EAAE,GAAE,EAAE;YAChE,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;gBAClD,OAAO,EAAE,IAAI;aAChB,CAAC,CAAA;QACN,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,4DAA4D,EAAE,GAAE,EAAE;YACjE,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;gBACnD,OAAO,EAAE,IAAI;aAChB,CAAC,CAAA;QACN,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,6DAA6D,EAAE,GAAE,EAAE;YAClE,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC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AAC,CAAA;QACN,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,sDAAsD,EAAE,GAAE,EAAE;YAC3D,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;gBACzD,OAAO,EAAE,KAAK;aACjB,CAAC,CAAA;QACN,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;IAEF,QAAQ,CAAC,8BAA8B,EAAE,GAAE,EAAE;QACzC,EAAE,CAAC,iCAAiC,EAAE,GAAE,EAAE;YACtC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,EAAC,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACrG,CAAC,CAAC,CAAA;QACF,EAAE,CAAC,uCAAuC,EAAE,GAAE,EAAE;YAC5C,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,EAAC,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACtG,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,kDAAkD,EAAE,GAAE,EAAE;YACvD,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,EAAC,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACpH,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/test/testBankAccountValidation.d.ts b/dist/test/testBankAccountValidation.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/dist/test/testBankAccountValidation.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/dist/test/testBankAccountValidation.js b/dist/test/testBankAccountValidation.js new file mode 100644 index 0000000..820d20f --- /dev/null +++ b/dist/test/testBankAccountValidation.js @@ -0,0 +1,24 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const chai = require("chai"); +const src_1 = require("../src"); +const IbanValidation_1 = require("../src/validators/IbanValidation"); +describe('BankAccountValidation', () => { + describe('when adding validators', () => { + it('it should be used to validate an account', () => { + let bankAccountValidation = new src_1.BankAccountValidation({}); + bankAccountValidation.add(new IbanValidation_1.IbanValidation({})); + chai.expect(bankAccountValidation.validate('DK5750510001322617')).to.deep.equal([{ + 'valid': true + }]); + }); + it('it should be used to invalidate an account', () => { + let bankAccountValidation = new src_1.BankAccountValidation({}); + bankAccountValidation.add(new IbanValidation_1.IbanValidation({})); + chai.expect(bankAccountValidation.validate('DK5750510001322618')).to.deep.equal([{ + 'valid': false + }]); + }); + }); +}); +//# sourceMappingURL=testBankAccountValidation.js.map \ No newline at end of file diff --git a/dist/test/testBankAccountValidation.js.map b/dist/test/testBankAccountValidation.js.map new file mode 100644 index 0000000..4bcfadc --- /dev/null +++ b/dist/test/testBankAccountValidation.js.map @@ -0,0 +1 @@ +{"version":3,"file":"testBankAccountValidation.js","sourceRoot":"","sources":["../../test/testBankAccountValidation.ts"],"names":[],"mappings":";;AAAA,6BAA4B;AAC5B,gCAA4C;AAC5C,qEAA+D;AAE/D,QAAQ,CAAC,uBAAuB,EAAE,GAAE,EAAE;IAClC,QAAQ,CAAC,wBAAwB,EAAE,GAAE,EAAE;QACnC,EAAE,CAAC,0CAA0C,EAAE,GAAE,EAAE;YAC/C,IAAI,qBAAqB,GAAG,IAAI,2BAAqB,CAAC,EAAE,CAAC,CAAA;YACzD,qBAAqB,CAAC,GAAG,CAAC,IAAI,+BAAc,CAAC,EAAE,CAAC,CAAC,CAAA;YACjD,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;oBACzE,OAAO,EAAE,IAAI;iBAChB,CAAC,CAAC,CAAA;QACX,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,4CAA4C,EAAE,GAAE,EAAE;YACjD,IAAI,qBAAqB,GAAG,IAAI,2BAAqB,CAAC,EAAE,CAAC,CAAA;YACzD,qBAAqB,CAAC,GAAG,CAAC,IAAI,+BAAc,CAAC,EAAE,CAAC,CAAC,CAAA;YACjD,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;oBACzE,OAAO,EAAE,KAAK;iBACjB,CAAC,CAAC,CAAA;QACX,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/test/testBankAccountValidation_.d.ts b/dist/test/testBankAccountValidation_.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/dist/test/testBankAccountValidation_.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/dist/test/testBankAccountValidation_.js b/dist/test/testBankAccountValidation_.js new file mode 100644 index 0000000..7a3c566 --- /dev/null +++ b/dist/test/testBankAccountValidation_.js @@ -0,0 +1,16 @@ +import * as chai from 'chai'; +import { BankAccountValidation } from '../src'; +import { IbanValidation } from '../src/IbanValidation'; +describe("BankAccountValidation", () => { + describe("when adding validators", () => { + it('it should be used', () => { + let a = new BankAccountValidation({ a: false }); + a.add(new IbanValidation({})); + }); + it('should ...', () => { + let a = new BankAccountValidation({ a: false }); + chai.expect(a.validate("")).to.deep.equal([]); + }); + }); +}); +//# sourceMappingURL=testBankAccountValidation_.js.map \ No newline at end of file diff --git a/dist/test/testBankAccountValidation_.js.map b/dist/test/testBankAccountValidation_.js.map new file mode 100644 index 0000000..f653abe --- /dev/null +++ b/dist/test/testBankAccountValidation_.js.map @@ -0,0 +1 @@ +{"version":3,"file":"testBankAccountValidation_.js","sourceRoot":"","sources":["../../test/testBankAccountValidation_.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,EAAC,qBAAqB,EAAC,MAAM,QAAQ,CAAA;AAC5C,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAA;AAEpD,QAAQ,CAAC,uBAAuB,EAAE,GAAE,EAAE;IAClC,QAAQ,CAAC,wBAAwB,EAAE,GAAE,EAAE;QACnC,EAAE,CAAC,mBAAmB,EAAE,GAAE,EAAE;YACxB,IAAI,CAAC,GAAG,IAAI,qBAAqB,CAAC,EAAC,CAAC,EAAC,KAAK,EAAC,CAAC,CAAA;YAC5C,CAAC,CAAC,GAAG,CAAC,IAAI,cAAc,CAAC,EAAE,CAAC,CAAC,CAAA;QACjC,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,YAAY,EAAE,GAAE,EAAE;YACjB,IAAI,CAAC,GAAG,IAAI,qBAAqB,CAAC,EAAC,CAAC,EAAC,KAAK,EAAC,CAAC,CAAA;YAC5C,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;QACjD,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/test/testIbanValidation.d.ts b/dist/test/testIbanValidation.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/dist/test/testIbanValidation.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/dist/test/testIbanValidation.js b/dist/test/testIbanValidation.js new file mode 100644 index 0000000..f91a639 --- /dev/null +++ b/dist/test/testIbanValidation.js @@ -0,0 +1,39 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const chai = require("chai"); +const IbanValidation_1 = require("../src/validators/IbanValidation"); +describe('IbanValidation', () => { + let validation; + beforeEach(() => { + validation = new IbanValidation_1.IbanValidation({}); + }); + describe('when validating', () => { + it('should validate a valid IBAN as string input', () => { + chai.expect(validation.validate('DK5750510001322617')).to.deep.equal({ + 'valid': true + }); + }); + it('should validate a valid IBAN as object input', () => { + chai.expect(validation.validate({ accountNumber: 'DK5750510001322617' })).to.deep.equal({ + 'valid': true + }); + }); + it('should invalidate an invalid IBAN', () => { + chai.expect(validation.validate('DK5750510001322618')).to.deep.equal({ + 'valid': false + }); + }); + }); + describe('when determining suitability', () => { + it('should accept a syntactically valid IBAN', () => { + chai.expect(validation.canValidate({ accountNumber: 'DK5750510001322618' })).to.equal(true); + }); + it('should not accept a syntactically invalid IBAN', () => { + chai.expect(validation.canValidate({ accountNumber: '9DK5750510001322618' })).to.equal(false); + }); + it('should not accept a type different from iban', () => { + chai.expect(validation.canValidate({ accountNumber: 'DK5750510001322618', type: 'bban' })).to.equal(false); + }); + }); +}); +//# sourceMappingURL=testIbanValidation.js.map \ No newline at end of file diff --git a/dist/test/testIbanValidation.js.map b/dist/test/testIbanValidation.js.map new file mode 100644 index 0000000..07ae570 --- /dev/null +++ b/dist/test/testIbanValidation.js.map @@ -0,0 +1 @@ +{"version":3,"file":"testIbanValidation.js","sourceRoot":"","sources":["../../test/testIbanValidation.ts"],"names":[],"mappings":";;AAAA,6BAA4B;AAC5B,qEAA+D;AAE/D,QAAQ,CAAC,gBAAgB,EAAE,GAAE,EAAE;IAC3B,IAAI,UAAyB,CAAA;IAC7B,UAAU,CAAC,GAAE,EAAE;QACX,UAAU,GAAG,IAAI,+BAAc,CAAC,EAAE,CAAC,CAAA;IACvC,CAAC,CAAC,CAAA;IAEF,QAAQ,CAAC,iBAAiB,EAAE,GAAE,EAAE;QAC5B,EAAE,CAAC,8CAA8C,EAAE,GAAE,EAAE;YACnD,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,oB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oB,EAAE,IAAI,EAAE,MAAM,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QAC5G,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/test/testSomething.d.ts b/dist/test/testSomething.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/dist/test/testSomething.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/dist/test/testSomething.js b/dist/test/testSomething.js new file mode 100644 index 0000000..0064952 --- /dev/null +++ b/dist/test/testSomething.js @@ -0,0 +1,12 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const chai = require("chai"); +describe('Something', () => { + it('should execute a simple test', () => { + console.log('Hello'); + }); + it('should fail', () => { + chai.expect(() => { throw new Error('failing'); }).to.throw(); + }); +}); +//# sourceMappingURL=testSomething.js.map \ No newline at end of file diff --git a/dist/test/testSomething.js.map b/dist/test/testSomething.js.map new file mode 100644 index 0000000..8cd0547 --- /dev/null +++ b/dist/test/testSomething.js.map @@ -0,0 +1 @@ +{"version":3,"file":"testSomething.js","sourceRoot":"","sources":["../../test/testSomething.ts"],"names":[],"mappings":";;AAAA,6BAA4B;AAE5B,QAAQ,CAAC,WAAW,EAAE,GAAE,EAAE;IACtB,EAAE,CAAC,8BAA8B,EAAE,GAAE,EAAE;QACnC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IACxB,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,aAAa,EAAE,GAAE,EAAE;QAClB,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,GAAE,MAAM,IAAI,KAAK,CAAC,SAAS,CAAC,CAAA,CAAA,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAA;IAC9D,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..7a3cad8 --- /dev/null +++ b/package.json @@ -0,0 +1,67 @@ +{ + "name": "njs-tfso-bankaccount-validation", + "version": "1.0.0", + "description": "Validation of IBAN and BBAN numbers and other country specific bank account formats. Extendable with custom validations", + "main": "dist/src/index", + "types": "dist/src/index", + "scripts": { + "build": "tsc", + "publish": "npm run build && publish-to-git --tag 1.0.0", + "test": "mocha --exit --recursive --timeout 10000 --require ts-node/register ./test/**/test*", + "cover": "nyc npm run test" + }, + "dependencies": { + "lodash.defaultsdeep": "4.6.0" + }, + "devDependencies": { + "@types/chai": "4.1.7", + "@types/lodash.defaultsdeep": "4.6.4", + "@types/mocha": "5.2.5", + "@types/sinon-chai": "3.2.2", + "chai": "4.2.0", + "ibantools": "2.0.0", + "mocha": "5.2.0", + "nyc": "13.1.0", + "publish-to-git": "github:tfso/publish-to-git", + "sinon-chai": "3.3.0", + "source-map-support": "0.5.9", + "ts-mocha": "2.0.0", + "ts-node": "7.0.1", + "typescript": "3.2.2" + }, + "nyc": { + "extension": [ + ".ts", + ".tsx" + ], + "exclude": [ + "**/*.d.ts" + ], + "reporter": [ + "html", + "text" + ] + }, + "repository": { + "type": "git", + "url": "git+https://github.com/tfso/njs-tfso-bankaccount-validation.git" + }, + "keywords": [ + "bankaccount", + "bank", + "account", + "validation", + "iban", + "bban" + ], + "author": "24SevenOffice", + "license": "MIT", + "bugs": { + "url": "https://github.com/tfso/njs-tfso-bankaccount-validation/issues" + }, + "homepage": "https://github.com/tfso/njs-tfso-bankaccount-validation#readme", + "files": [ + "dist", + "src" + ] +} diff --git a/src/BankAccountValidation.ts b/src/BankAccountValidation.ts new file mode 100644 index 0000000..6c3c50d --- /dev/null +++ b/src/BankAccountValidation.ts @@ -0,0 +1,28 @@ +import * as types from './types' +import defaultsDeep = require('lodash.defaultsdeep') +import defaultConfig from './defaultConfig' +import {ValidationInput} from "./types" + +export class BankAccountValidation{ + _config: types.BankAccountValidationConfig + _validationRules: types.IValidation[] + + constructor(config: Partial){ + this._config = defaultsDeep({}, config, defaultConfig) + this._validationRules = [] + } + + add(validationRule: types.IValidation){ + this._validationRules.push(validationRule) + } + + validate(input:string|ValidationInput){ + return this._validationRules + .filter(validationRule =>{ + return validationRule.canValidate(input) + }) + .map(validationRule =>{ + return validationRule.validate(input) + }) + } +} \ No newline at end of file diff --git a/src/createBankAccountValidation.ts b/src/createBankAccountValidation.ts new file mode 100644 index 0000000..245cb49 --- /dev/null +++ b/src/createBankAccountValidation.ts @@ -0,0 +1,17 @@ +import { BankAccountValidation } from '../src' +import * as types from "./types" +import {SwedishBankgiroValidation} from "./validators/SwedishBankgiroValidation" +import {SwedishPlusgiroValidation} from "./validators/SwedishPlusgiroValidation" +import {SwedishBbanValidation} from "./validators/SwedishBbanValidation" +import {NorwegianBbanValidation} from "./validators/NorwegianBbanValidation" +import {IbanValidation} from "./validators/IbanValidation" + +export function createValidationWithAllAvailableValidators(config: Partial){ + let bankAccountValidation = new BankAccountValidation(config) + bankAccountValidation.add(new IbanValidation(config)) + bankAccountValidation.add(new SwedishBankgiroValidation(config)) + bankAccountValidation.add(new SwedishPlusgiroValidation(config)) + bankAccountValidation.add(new SwedishBbanValidation(config)) + bankAccountValidation.add(new NorwegianBbanValidation(config)) + return bankAccountValidation +} \ No newline at end of file diff --git a/src/defaultConfig.ts b/src/defaultConfig.ts new file mode 100644 index 0000000..29b1ecf --- /dev/null +++ b/src/defaultConfig.ts @@ -0,0 +1,2 @@ +export default { +} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..55f46f5 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,2 @@ +export {BankAccountValidation} from './BankAccountValidation' +export {createValidationWithAllAvailableValidators} from './createBankAccountValidation' diff --git a/src/types.ts b/src/types.ts new file mode 100644 index 0000000..c6d2087 --- /dev/null +++ b/src/types.ts @@ -0,0 +1,17 @@ +export interface BankAccountValidationConfig{ +} + +export interface ValidationInput{ + accountNumber: string + countryCode?: string + type?: string +} + +export interface ValidationResult{ + valid: Boolean +} + +export interface IValidation{ + validate(input:any): ValidationResult + canValidate(input:any): Boolean +} diff --git a/src/util/modulusCalculation.ts b/src/util/modulusCalculation.ts new file mode 100644 index 0000000..b7522c3 --- /dev/null +++ b/src/util/modulusCalculation.ts @@ -0,0 +1,28 @@ +function normaizeWeights(weights: number[], length: number) { + let _weights = weights + while (_weights.length < length) { + _weights = _weights.concat(weights) + } + while (_weights.length > length) { + _weights.shift() + } + + return _weights +} + +export function calculate(number: string, weights: number[], postProcess:any = (n:any) => n) { + weights = normaizeWeights(weights, number.length) + + let sum:number = 0 + for (let i:number = 0; i < number.length; i++) { + sum += postProcess(parseInt(number[i]) * weights[i]) + } + + return sum +} + + +export function modulusValidation(sum:number, modulus: number) { + let modValue = sum / modulus + return (modValue - Math.floor(modValue)) === 0 +} \ No newline at end of file diff --git a/src/util/standarizeInput.ts b/src/util/standarizeInput.ts new file mode 100644 index 0000000..06e2b61 --- /dev/null +++ b/src/util/standarizeInput.ts @@ -0,0 +1,22 @@ +import {ValidationInput} from "../types" + +// export function standarizeInput(input: string | ValidationInput):ValidationInput { +// let result:ValidationInput +// if (typeof input === "string") { +// result = { +// accountNumber: input +// } +// } else { +// result = input +// } +// return result +// } + +export function standarizeInput(input: string | ValidationInput):ValidationInput { + if (typeof input === "string") { + input = { + accountNumber: input + } + } + return input +} \ No newline at end of file diff --git a/src/util/swedishBanks.ts b/src/util/swedishBanks.ts new file mode 100644 index 0000000..28c94e2 --- /dev/null +++ b/src/util/swedishBanks.ts @@ -0,0 +1,394 @@ +export const swedishBanks: any[] = [ + { + "bank": "Amfa Bank AB", + "clearingFrom": 9660, + "clearingTo": 9669, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Avanza Bank AB (deltar endast i dataclearingen, ej i bankgirosystemet)", + "clearingFrom": 9550, + "clearingTo": 9569, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "BlueStep Finans AB (deltar endast i dataclearingen, ej i Bankgirosystemet)", + "clearingFrom": 9680, + "clearingTo": 9689, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "BNP Paribas Fortis Bank", + "clearingFrom": 9470, + "clearingTo": 9479, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Citibank", + "clearingFrom": 9040, + "clearingTo": 9049, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Danske Bank", + "clearingFrom": 1200, + "clearingTo": 1399, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "Danske Bank", + "clearingFrom": 2400, + "clearingTo": 2499, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "DNB Bank", + "clearingFrom": 9190, + "clearingTo": 9199, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "DNB Bank", + "clearingFrom": 9260, + "clearingTo": 9269, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Ekobanken", + "clearingFrom": 9700, + "clearingTo": 9709, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Erik Penser AB (deltar endast i dataclearingen, ej i bankgirosystemet)", + "clearingFrom": 9590, + "clearingTo": 9599, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Forex Bank", + "clearingFrom": 9400, + "clearingTo": 9449, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "ICA Banken AB", + "clearingFrom": 9270, + "clearingTo": 9279, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "IKANO Bank", + "clearingFrom": 9170, + "clearingTo": 9179, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "JAK Medlemsbank (deltar endast i dataclearingen, ej i bankgirosystemet)", + "clearingFrom": 9670, + "clearingTo": 9679, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Landshypotek AB (deltar endast i dataclearingen, ej i bankgirosystemet)", + "clearingFrom": 9390, + "clearingTo": 9399, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "L%uFFFDn & Spar Bank Sverige (deltar endast i dataclearingen, ej i bankgirosystemet)", + "clearingFrom": 9630, + "clearingTo": 9639, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "L%uFFFDnsf%uFFFDrs%uFFFDkringar Bank", + "clearingFrom": 3400, + "clearingTo": 3409, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "L%uFFFDnsf%uFFFDrs%uFFFDkringar Bank", + "clearingFrom": 9020, + "clearingTo": 9029, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "L%uFFFDnsf%uFFFDrs%uFFFDkringar Bank", + "clearingFrom": 9060, + "clearingTo": 9069, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "Marginalen Bank", + "clearingFrom": 9230, + "clearingTo": 9239, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "Nordax Bank AB", + "clearingFrom": 9640, + "clearingTo": 9649, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Nordea", + "clearingFrom": 1100, + "clearingTo": 1199, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "Nordea", + "clearingFrom": 1400, + "clearingTo": 2099, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "Nordea (exkl. personkonton, cl 3300)", + "clearingFrom": 3000, + "clearingTo": 3399, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "Nordea (exkl. personkonton, cl 3782)", + "clearingFrom": 3410, + "clearingTo": 3999, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "Nordea", + "clearingFrom": 4000, + "clearingTo": 4999, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Nordnet Bank", + "clearingFrom": 9100, + "clearingTo": 9109, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Resurs Bank", + "clearingFrom": 9280, + "clearingTo": 9289, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "Riksg%uFFFDlden", + "clearingFrom": 9880, + "clearingTo": 9889, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Royal bank of Scotland", + "clearingFrom": 9090, + "clearingTo": 9099, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Santander Consumer Bank AS (deltar endast i dataclearingen, ej i bankgirosystemet)", + "clearingFrom": 9460, + "clearingTo": 9469, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "SBAB", + "clearingFrom": 9250, + "clearingTo": 9259, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "SEB", + "clearingFrom": 5000, + "clearingTo": 5999, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "SEB", + "clearingFrom": 9120, + "clearingTo": 9124, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "SEB", + "clearingFrom": 9130, + "clearingTo": 9149, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "Skandiabanken", + "clearingFrom": 9150, + "clearingTo": 9169, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Swedbank", + "clearingFrom": 7000, + "clearingTo": 7999, + "format": "00000xxxxxxC", + "type": 1, + "comment": 1 + }, + { + "bank": "%uFFFDlandsbanken Sverige AB", + "clearingFrom": 2300, + "clearingTo": 2399, + "format": "00000xxxxxxC", + "type": 1, + "comment": 2 + }, + { + "bank": "Danske Bank", + "clearingFrom": 9180, + "clearingTo": 9189, + "format": "00xxxxxxxxxC", + "type": 2, + "comment": 1 + }, + { + "bank": "Handelsbanken", + "clearingFrom": 6000, + "clearingTo": 6999, + "format": "000xxxxxxxxC", + "type": 2, + "comment": 2 + }, + { + "bank": "Nordea/Plusgirot", + "clearingFrom": 9500, + "clearingTo": 9549, + "format": "00xxxxxxxxxC", + "type": 2, + "comment": 3 + }, + { + "bank": "Nordea/Plusgirot", + "clearingFrom": 9960, + "clearingTo": 9969, + "format": "00xxxxxxxxxC", + "type": 2, + "comment": 3 + }, + { + "bank": "Nordea - personkonto", + "clearingFrom": 3300, + "clearingTo": 3782, + "format": "00xxxxxxxxxC", + "type": 2, + "comment": 1 + }, + { + "bank": "Riksg%uFFFDlden", + "clearingFrom": 9890, + "clearingTo": 9899, + "format": "00xxxxxxxxxC", + "type": 2, + "comment": 1 + }, + { + "bank": "Sparbanken Syd", + "clearingFrom": 9570, + "clearingTo": 9579, + "format": "00xxxxxxxxxC", + "type": 2, + "comment": 1 + }, + { + "bank": "Swedbank", + "clearingFrom": 8000, + "clearingTo": 8999, + "format": "00xxxxxxxxxC", + "type": 2, + "comment": 3 + }, + { + "bank": "Swedbank (f.d. Sparbanken %uFFFDresund)", + "clearingFrom": 9300, + "clearingTo": 9329, + "format": "00xxxxxxxxxC", + "type": 2, + "comment": 1 + }, + { + "bank": "Swedbank (f.d. Sparbanken %uFFFDresund)", + "clearingFrom": 9330, + "clearingTo": 9349, + "format": "00xxxxxxxxxC", + "type": 2, + "comment": 1 + } +] \ No newline at end of file diff --git a/src/validators/IbanValidation.ts b/src/validators/IbanValidation.ts new file mode 100644 index 0000000..7976bfc --- /dev/null +++ b/src/validators/IbanValidation.ts @@ -0,0 +1,31 @@ +import defaultsDeep = require('lodash.defaultsdeep') +import * as types from "../types" +import {IValidation, ValidationInput} from "../types" +import defaultConfig from "../defaultConfig" +import {standarizeInput} from "../util/standarizeInput" +import * as ibantools from "ibantools" + +export class IbanValidation implements IValidation { + _config: types.BankAccountValidationConfig + private _syntaxTester: RegExp + + constructor(config: Partial) { + this._config = defaultsDeep({}, config, defaultConfig) + this._syntaxTester = /^[A-Z]{2}\d{2}.*$/ + } + + canValidate(input: string | ValidationInput): Boolean { + input = standarizeInput(input) + + return (!input.type || input.type === 'iban') + && this._syntaxTester.test(input.accountNumber) + } + + validate(input: string | ValidationInput) { + input = standarizeInput(input) + + return { + valid: ibantools.isValidIBAN(input.accountNumber) + } + } +} \ No newline at end of file diff --git a/src/validators/NorwegianBbanValidation.ts b/src/validators/NorwegianBbanValidation.ts new file mode 100644 index 0000000..ab2f689 --- /dev/null +++ b/src/validators/NorwegianBbanValidation.ts @@ -0,0 +1,37 @@ +import defaultsDeep = require('lodash.defaultsdeep') +import * as types from "../types" +import {IValidation, ValidationInput} from "../types" +import defaultConfig from "../defaultConfig" +import {standarizeInput} from "../util/standarizeInput" +// import * as checkdigit from 'checkdigit' +import {calculate, modulusValidation} from '../util/modulusCalculation' + +export class NorwegianBbanValidation implements IValidation { + _config: types.BankAccountValidationConfig + private _syntaxTester: RegExp + + constructor(config: Partial) { + this._config = defaultsDeep({}, config, defaultConfig) + this._syntaxTester = /^\d{11}$/ + } + + canValidate(input: string | ValidationInput): Boolean { + input = standarizeInput(input) + + return (!input.type || input.type === 'bban') + && input.countryCode === 'NO' + } + + validate(input: string | ValidationInput) { + input = standarizeInput(input) + + return { + valid: this._syntaxTester.test(input.accountNumber) && + norMod11(input.accountNumber) + } + } +} +function norMod11(number:string){ + let sum = calculate(number, [5, 4, 3, 2, 7, 6, 5, 4, 3, 2, 1]) + return modulusValidation(sum, 11) +} \ No newline at end of file diff --git a/src/validators/SwedishBankgiroValidation.ts b/src/validators/SwedishBankgiroValidation.ts new file mode 100644 index 0000000..bed83be --- /dev/null +++ b/src/validators/SwedishBankgiroValidation.ts @@ -0,0 +1,30 @@ +import defaultsDeep = require('lodash.defaultsdeep') +import * as types from "../types" +import {IValidation, ValidationInput} from "../types" +import defaultConfig from "../defaultConfig" +import {standarizeInput} from "../util/standarizeInput" + +export class SwedishBankgiroValidation implements IValidation { + _config: types.BankAccountValidationConfig + private _syntaxTester: RegExp + + constructor(config: Partial) { + this._config = defaultsDeep({}, config, defaultConfig) + this._syntaxTester = /^\d{3,4}-\d{4}$/ + } + + canValidate(input: string | ValidationInput): Boolean { + input = standarizeInput(input) + + return (!input.type || input.type === 'bankgiro') + && input.countryCode === 'SE' + } + + validate(input: string | ValidationInput) { + input = standarizeInput(input) + + return { + valid: this._syntaxTester.test(input.accountNumber) + } + } +} \ No newline at end of file diff --git a/src/validators/SwedishBbanValidation.ts b/src/validators/SwedishBbanValidation.ts new file mode 100644 index 0000000..ff08a01 --- /dev/null +++ b/src/validators/SwedishBbanValidation.ts @@ -0,0 +1,97 @@ +import defaultsDeep = require('lodash.defaultsdeep') +import * as types from "../types" +import {IValidation, ValidationInput} from "../types" +import defaultConfig from "../defaultConfig" +import {swedishBanks} from "../util/swedishBanks" +import {standarizeInput} from "../util/standarizeInput" +import {calculate, modulusValidation} from '../util/modulusCalculation' + +interface Account{ + clearing: number + accountNumber: string, + bban: string, + type: string + length: number +} + +export class SwedishBbanValidation implements IValidation { + _config: types.BankAccountValidationConfig + private _syntaxTester: RegExp + + constructor(config: Partial) { + this._config = defaultsDeep({}, config, defaultConfig) + /* syntax: clearing (4 digit) + account number (7, 9 or 10 digit) */ + this._syntaxTester = /^\d{4}(:?\d{7}|\d{9}|\d{10})$/ + } + + canValidate(input: string | ValidationInput): Boolean { + input = standarizeInput(input) + + return (!input.type || input.type === 'bban') + && input.countryCode === 'SE' + } + + validate(input: string | ValidationInput) { + input = standarizeInput(input) + let bban = input.accountNumber + + let valid = this._syntaxTester.test(bban) + + if (!valid){ + return {valid:false} + } + + let account = this.parseBban(bban) + + if ( + account.type === '1.1' && account.length === 7 && sweMod11(account.bban.substr(1)) || + account.type === '1.2' && account.length === 7 && sweMod11(account.bban) || + account.type === '2.1' && account.length === 10 && sweMod10(account.accountNumber) || + account.type === '2.2' && account.length === 9 && sweMod11(account.accountNumber) || + account.type === '2.3' && account.length === 10 && sweMod10(account.accountNumber) + ){ + return {valid:true} + } + + return {valid:false} + } + + private parseBban(bban:string):Account { + let clearing = parseInt(bban.substr(0,4)) + let accountNumber = bban.substr(4) + let type = this.getType(clearing) + + return { + clearing, + accountNumber, + bban, + type, + length: accountNumber.length + } + } + + private getType(clearingNumber:number):string { + let banks = swedishBanks.filter(bank => { + return bank.clearingFrom <= clearingNumber && clearingNumber <= bank.clearingTo + }) + + if (banks.length !== 1 ) { + return '0.0' + } + + let bank = banks[0] + + return bank.type + '.' + bank.comment + } +} + + +function sweMod10(number:string){ + let sum = calculate(number, [2,1], (n:any) => n>9 ? n-9:n) + return modulusValidation(sum, 10) +} + +function sweMod11(number:string){ + let sum = calculate(number, [10,9,8,7,6,5,4,3,2,1]) + return modulusValidation(sum, 11) +} \ No newline at end of file diff --git a/src/validators/SwedishPlusgiroValidation.ts b/src/validators/SwedishPlusgiroValidation.ts new file mode 100644 index 0000000..5e68030 --- /dev/null +++ b/src/validators/SwedishPlusgiroValidation.ts @@ -0,0 +1,30 @@ +import defaultsDeep = require('lodash.defaultsdeep') +import * as types from "../types" +import {IValidation, ValidationInput} from "../types" +import defaultConfig from "../defaultConfig" +import {standarizeInput} from "../util/standarizeInput" + +export class SwedishPlusgiroValidation implements IValidation { + _config: types.BankAccountValidationConfig + private _syntaxTester: RegExp + + constructor(config: Partial) { + this._config = defaultsDeep({}, config, defaultConfig) + this._syntaxTester = /^(\d{1,7})-\d$/ + } + + canValidate(input: string | ValidationInput): Boolean { + input = standarizeInput(input) + + return (!input.type || input.type === 'plusgiro') + && input.countryCode === 'SE' + } + + validate(input: string | ValidationInput) { + input = standarizeInput(input) + + return { + valid: this._syntaxTester.test(input.accountNumber) + } + } +} \ No newline at end of file