ibantools 4.5.0 → 4.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,7 +12,7 @@
12
12
  * @package Documentation
13
13
  * @author Saša Jovanić
14
14
  * @module ibantools
15
- * @version 4.5.0
15
+ * @version 4.5.2
16
16
  * @license MIT or MPL-2.0
17
17
  * @preferred
18
18
  */
@@ -36,13 +36,12 @@
36
36
  * ibantools.isValidIBAN('CH4431999123000889012', { allowQRIBAN: false });
37
37
  * ```
38
38
  */
39
- export function isValidIBAN(iban, validationOptions) {
40
- if (validationOptions === void 0) { validationOptions = { allowQRIBAN: true }; }
39
+ export function isValidIBAN(iban, validationOptions = { allowQRIBAN: true }) {
41
40
  if (iban === undefined || iban === null)
42
41
  return false;
43
- var reg = new RegExp('^[0-9]{2}$', '');
44
- var countryCode = iban.slice(0, 2);
45
- var spec = countrySpecs[countryCode];
42
+ const reg = new RegExp('^[0-9]{2}$', '');
43
+ const countryCode = iban.slice(0, 2);
44
+ const spec = countrySpecs[countryCode];
46
45
  if (spec === undefined || spec.bban_regexp === undefined || spec.bban_regexp === null || spec.chars === undefined)
47
46
  return false;
48
47
  return (spec.chars === iban.length &&
@@ -81,11 +80,10 @@ export var ValidationErrorsIBAN;
81
80
  * ibantools.validateIBAN('CH4431999123000889012', { allowQRIBAN: false });
82
81
  * ```
83
82
  */
84
- export function validateIBAN(iban, validationOptions) {
85
- if (validationOptions === void 0) { validationOptions = { allowQRIBAN: true }; }
86
- var result = { errorCodes: [], valid: true };
83
+ export function validateIBAN(iban, validationOptions = { allowQRIBAN: true }) {
84
+ const result = { errorCodes: [], valid: true };
87
85
  if (iban !== undefined && iban !== null && iban !== '') {
88
- var spec = countrySpecs[iban.slice(0, 2)];
86
+ const spec = countrySpecs[iban.slice(0, 2)];
89
87
  if (!spec || !(spec.bban_regexp || spec.chars)) {
90
88
  result.valid = false;
91
89
  result.errorCodes.push(ValidationErrorsIBAN.NoIBANCountry);
@@ -103,7 +101,7 @@ export function validateIBAN(iban, validationOptions) {
103
101
  result.valid = false;
104
102
  result.errorCodes.push(ValidationErrorsIBAN.WrongAccountBankBranchChecksum);
105
103
  }
106
- var reg = new RegExp('^[0-9]{2}$', '');
104
+ const reg = new RegExp('^[0-9]{2}$', '');
107
105
  if (!reg.test(iban.slice(2, 4))) {
108
106
  result.valid = false;
109
107
  result.errorCodes.push(ValidationErrorsIBAN.ChecksumNotNumber);
@@ -138,7 +136,7 @@ export function validateIBAN(iban, validationOptions) {
138
136
  export function isValidBBAN(bban, countryCode) {
139
137
  if (bban === undefined || bban === null || countryCode === undefined || countryCode === null)
140
138
  return false;
141
- var spec = countrySpecs[countryCode];
139
+ const spec = countrySpecs[countryCode];
142
140
  if (spec === undefined ||
143
141
  spec === null ||
144
142
  spec.bban_regexp === undefined ||
@@ -167,7 +165,7 @@ export function isValidBBAN(bban, countryCode) {
167
165
  */
168
166
  export function isSEPACountry(countryCode) {
169
167
  if (countryCode !== undefined && countryCode !== null) {
170
- var spec = countrySpecs[countryCode];
168
+ const spec = countrySpecs[countryCode];
171
169
  if (spec !== undefined) {
172
170
  return spec.SEPA ? spec.SEPA : false;
173
171
  }
@@ -188,11 +186,11 @@ export function isSEPACountry(countryCode) {
188
186
  export function isQRIBAN(iban) {
189
187
  if (iban === undefined || iban === null)
190
188
  return false;
191
- var countryCode = iban.slice(0, 2);
192
- var QRIBANCountries = ['LI', 'CH'];
189
+ const countryCode = iban.slice(0, 2);
190
+ const QRIBANCountries = ['LI', 'CH'];
193
191
  if (!QRIBANCountries.includes(countryCode))
194
192
  return false;
195
- var reg = new RegExp('^3[0-1]{1}[0-9]{3}$', '');
193
+ const reg = new RegExp('^3[0-1]{1}[0-9]{3}$', '');
196
194
  return reg.test(iban.slice(4, 9));
197
195
  }
198
196
  /**
@@ -204,11 +202,11 @@ export function isQRIBAN(iban) {
204
202
  * ```
205
203
  */
206
204
  export function composeIBAN(params) {
207
- var formated_bban = electronicFormatIBAN(params.bban) || '';
205
+ const formated_bban = electronicFormatIBAN(params.bban) || '';
208
206
  if (params.countryCode === null || params.countryCode === undefined) {
209
207
  return null;
210
208
  }
211
- var spec = countrySpecs[params.countryCode];
209
+ const spec = countrySpecs[params.countryCode];
212
210
  if (formated_bban !== '' &&
213
211
  spec !== undefined &&
214
212
  spec.chars &&
@@ -217,7 +215,7 @@ export function composeIBAN(params) {
217
215
  spec.bban_regexp &&
218
216
  spec.bban_regexp !== null &&
219
217
  checkFormatBBAN(formated_bban, spec.bban_regexp)) {
220
- var checksom = mod9710Iban(params.countryCode + '00' + formated_bban);
218
+ const checksom = mod9710Iban(params.countryCode + '00' + formated_bban);
221
219
  return params.countryCode + ('0' + (98 - checksom)).slice(-2) + formated_bban;
222
220
  }
223
221
  return null;
@@ -230,30 +228,30 @@ export function composeIBAN(params) {
230
228
  * ```
231
229
  */
232
230
  export function extractIBAN(iban) {
233
- var result = {};
234
- var eFormatIBAN = electronicFormatIBAN(iban);
231
+ const result = {};
232
+ const eFormatIBAN = electronicFormatIBAN(iban);
235
233
  result.iban = eFormatIBAN || iban;
236
234
  if (!!eFormatIBAN && isValidIBAN(eFormatIBAN)) {
237
235
  result.bban = eFormatIBAN.slice(4);
238
236
  result.countryCode = eFormatIBAN.slice(0, 2);
239
237
  result.valid = true;
240
- var spec = countrySpecs[result.countryCode];
238
+ const spec = countrySpecs[result.countryCode];
241
239
  if (spec.account_indentifier) {
242
- var ac = spec.account_indentifier.split('-');
243
- var starting = parseInt(ac[0]);
244
- var ending = parseInt(ac[1]);
240
+ const ac = spec.account_indentifier.split('-');
241
+ const starting = parseInt(ac[0]);
242
+ const ending = parseInt(ac[1]);
245
243
  result.accountNumber = result.iban.slice(starting, ending + 1);
246
244
  }
247
245
  if (spec.bank_identifier) {
248
- var ac = spec.bank_identifier.split('-');
249
- var starting = parseInt(ac[0]);
250
- var ending = parseInt(ac[1]);
246
+ const ac = spec.bank_identifier.split('-');
247
+ const starting = parseInt(ac[0]);
248
+ const ending = parseInt(ac[1]);
251
249
  result.bankIdentifier = result.bban.slice(starting, ending + 1);
252
250
  }
253
251
  if (spec.branch_indentifier) {
254
- var ac = spec.branch_indentifier.split('-');
255
- var starting = parseInt(ac[0]);
256
- var ending = parseInt(ac[1]);
252
+ const ac = spec.branch_indentifier.split('-');
253
+ const starting = parseInt(ac[0]);
254
+ const ending = parseInt(ac[1]);
257
255
  result.branchIdentifier = result.bban.slice(starting, ending + 1);
258
256
  }
259
257
  }
@@ -268,7 +266,7 @@ export function extractIBAN(iban) {
268
266
  * @ignore
269
267
  */
270
268
  function checkFormatBBAN(bban, bformat) {
271
- var reg = new RegExp(bformat, '');
269
+ const reg = new RegExp(bformat, '');
272
270
  return reg.test(bban);
273
271
  }
274
272
  /**
@@ -306,7 +304,7 @@ export function friendlyFormatIBAN(iban, separator) {
306
304
  if (separator === undefined || separator === null) {
307
305
  separator = ' ';
308
306
  }
309
- var electronic_iban = electronicFormatIBAN(iban);
307
+ const electronic_iban = electronicFormatIBAN(iban);
310
308
  /* istanbul ignore if */
311
309
  if (electronic_iban === null) {
312
310
  return null;
@@ -319,9 +317,9 @@ export function friendlyFormatIBAN(iban, separator) {
319
317
  * @ignore
320
318
  */
321
319
  function isValidIBANChecksum(iban) {
322
- var countryCode = iban.slice(0, 2);
323
- var providedChecksum = parseInt(iban.slice(2, 4), 10);
324
- var bban = iban.slice(4);
320
+ const countryCode = iban.slice(0, 2);
321
+ const providedChecksum = parseInt(iban.slice(2, 4), 10);
322
+ const bban = iban.slice(4);
325
323
  // Wikipedia[validating_iban] says there are a specif way to check if a IBAN is valid but
326
324
  // it. It says 'If the remainder is 1, the check digit test is passed and the
327
325
  // IBAN might be valid.'. might, MIGHT!
@@ -339,8 +337,8 @@ function isValidIBANChecksum(iban) {
339
337
  //
340
338
  // [validating_iban][https://en.wikipedia.org/wiki/International_Bank_Account_Number#Validating_the_IBAN]
341
339
  // [generating-iban-check][https://en.wikipedia.org/wiki/International_Bank_Account_Number#Generating_IBAN_check_digits]
342
- var validationString = replaceCharaterWithCode("".concat(bban).concat(countryCode, "00"));
343
- var rest = mod9710(validationString);
340
+ const validationString = replaceCharaterWithCode(`${bban}${countryCode}00`);
341
+ const rest = mod9710(validationString);
344
342
  return 98 - rest === providedChecksum;
345
343
  }
346
344
  /**
@@ -354,8 +352,8 @@ function replaceCharaterWithCode(str) {
354
352
  // https://jsbench.me/ttkzgsekae/1
355
353
  return str
356
354
  .split('')
357
- .map(function (c) {
358
- var code = c.charCodeAt(0);
355
+ .map((c) => {
356
+ const code = c.charCodeAt(0);
359
357
  return code >= 65 ? (code - 55).toString() : c;
360
358
  })
361
359
  .join('');
@@ -391,9 +389,9 @@ function mod9710Iban(iban) {
391
389
  * ```
392
390
  */
393
391
  export function getCountrySpecifications() {
394
- var countyMap = {};
395
- for (var countyCode in countrySpecs) {
396
- var county = countrySpecs[countyCode];
392
+ const countyMap = {};
393
+ for (const countyCode in countrySpecs) {
394
+ const county = countrySpecs[countyCode];
397
395
  countyMap[countyCode] = {
398
396
  chars: county.chars || null,
399
397
  bban_regexp: county.bban_regexp || null,
@@ -424,8 +422,8 @@ export function isValidBIC(bic) {
424
422
  if (!bic) {
425
423
  return false;
426
424
  }
427
- var reg = new RegExp('^[a-zA-Z]{6}[a-zA-Z0-9]{2}([a-zA-Z0-9]{3})?$', '');
428
- var spec = countrySpecs[bic.toUpperCase().slice(4, 6)];
425
+ const reg = new RegExp('^[a-zA-Z]{6}[a-zA-Z0-9]{2}([a-zA-Z0-9]{3})?$', '');
426
+ const spec = countrySpecs[bic.toUpperCase().slice(4, 6)];
429
427
  return reg.test(bic) && spec !== undefined;
430
428
  }
431
429
  /**
@@ -445,15 +443,15 @@ export var ValidationErrorsBIC;
445
443
  * ```
446
444
  */
447
445
  export function validateBIC(bic) {
448
- var result = { errorCodes: [], valid: true };
446
+ const result = { errorCodes: [], valid: true };
449
447
  if (bic !== undefined && bic !== null && bic !== '') {
450
- var spec = countrySpecs[bic.toUpperCase().slice(4, 6)];
448
+ const spec = countrySpecs[bic.toUpperCase().slice(4, 6)];
451
449
  if (spec === undefined) {
452
450
  result.valid = false;
453
451
  result.errorCodes.push(ValidationErrorsBIC.NoBICCountry);
454
452
  }
455
453
  else {
456
- var reg = new RegExp('^[a-zA-Z]{6}[a-zA-Z0-9]{2}([a-zA-Z0-9]{3})?$', '');
454
+ const reg = new RegExp('^[a-zA-Z]{6}[a-zA-Z0-9]{2}([a-zA-Z0-9]{3})?$', '');
457
455
  if (!reg.test(bic)) {
458
456
  result.valid = false;
459
457
  result.errorCodes.push(ValidationErrorsBIC.WrongBICFormat);
@@ -474,8 +472,8 @@ export function validateBIC(bic) {
474
472
  * ```
475
473
  */
476
474
  export function extractBIC(inputBic) {
477
- var result = {};
478
- var bic = inputBic.toUpperCase();
475
+ const result = {};
476
+ const bic = inputBic.toUpperCase();
479
477
  if (isValidBIC(bic)) {
480
478
  result.bankCode = bic.slice(0, 4);
481
479
  result.countryCode = bic.slice(4, 6);
@@ -494,16 +492,16 @@ export function extractBIC(inputBic) {
494
492
  *
495
493
  * @ignore
496
494
  */
497
- var checkNorwayBBAN = function (bban) {
498
- var weights = [5, 4, 3, 2, 7, 6, 5, 4, 3, 2];
499
- var bbanWithoutSpacesAndPeriods = bban.replace(/[\s.]+/g, '');
500
- var controlDigit = parseInt(bbanWithoutSpacesAndPeriods.charAt(10), 10);
501
- var bbanWithoutControlDigit = bbanWithoutSpacesAndPeriods.substring(0, 10);
502
- var sum = 0;
503
- for (var index = 0; index < 10; index++) {
495
+ const checkNorwayBBAN = (bban) => {
496
+ const weights = [5, 4, 3, 2, 7, 6, 5, 4, 3, 2];
497
+ const bbanWithoutSpacesAndPeriods = bban.replace(/[\s.]+/g, '');
498
+ const controlDigit = parseInt(bbanWithoutSpacesAndPeriods.charAt(10), 10);
499
+ const bbanWithoutControlDigit = bbanWithoutSpacesAndPeriods.substring(0, 10);
500
+ let sum = 0;
501
+ for (let index = 0; index < 10; index++) {
504
502
  sum += parseInt(bbanWithoutControlDigit.charAt(index), 10) * weights[index];
505
503
  }
506
- var remainder = sum % 11;
504
+ const remainder = sum % 11;
507
505
  return controlDigit === (remainder === 0 ? 0 : 11 - remainder);
508
506
  };
509
507
  /**
@@ -511,11 +509,11 @@ var checkNorwayBBAN = function (bban) {
511
509
  *
512
510
  * @ignore
513
511
  */
514
- var checkBelgianBBAN = function (bban) {
515
- var stripped = bban.replace(/[\s.]+/g, '');
516
- var checkingPart = parseInt(stripped.substring(0, stripped.length - 2), 10);
517
- var checksum = parseInt(stripped.substring(stripped.length - 2, stripped.length), 10);
518
- var remainder = checkingPart % 97 === 0 ? 97 : checkingPart % 97;
512
+ const checkBelgianBBAN = (bban) => {
513
+ const stripped = bban.replace(/[\s.]+/g, '');
514
+ const checkingPart = parseInt(stripped.substring(0, stripped.length - 2), 10);
515
+ const checksum = parseInt(stripped.substring(stripped.length - 2, stripped.length), 10);
516
+ const remainder = checkingPart % 97 === 0 ? 97 : checkingPart % 97;
519
517
  return remainder === checksum;
520
518
  };
521
519
  /**
@@ -523,15 +521,15 @@ var checkBelgianBBAN = function (bban) {
523
521
  *
524
522
  * @ignore
525
523
  */
526
- var mod9710 = function (validationString) {
524
+ const mod9710 = (validationString) => {
527
525
  while (validationString.length > 2) {
528
526
  // > Any computer programming language or software package that is used to compute D
529
527
  // > mod 97 directly must have the ability to handle integers of more than 30 digits.
530
528
  // > In practice, this can only be done by software that either supports
531
529
  // > arbitrary-precision arithmetic or that can handle 219-bit (unsigned) integers
532
530
  // https://en.wikipedia.org/wiki/International_Bank_Account_Number#Modulo_operation_on_IBAN
533
- var part = validationString.slice(0, 6);
534
- var partInt = parseInt(part, 10);
531
+ const part = validationString.slice(0, 6);
532
+ const partInt = parseInt(part, 10);
535
533
  if (isNaN(partInt)) {
536
534
  return NaN;
537
535
  }
@@ -545,9 +543,9 @@ var mod9710 = function (validationString) {
545
543
  *
546
544
  * @ignore
547
545
  */
548
- var checkMod9710BBAN = function (bban) {
549
- var stripped = bban.replace(/[\s.]+/g, '');
550
- var reminder = mod9710(stripped);
546
+ const checkMod9710BBAN = (bban) => {
547
+ const stripped = bban.replace(/[\s.]+/g, '');
548
+ const reminder = mod9710(stripped);
551
549
  return reminder === 1;
552
550
  };
553
551
  /**
@@ -555,15 +553,15 @@ var checkMod9710BBAN = function (bban) {
555
553
  *
556
554
  * @ignore
557
555
  */
558
- var checkPolandBBAN = function (bban) {
559
- var weights = [3, 9, 7, 1, 3, 9, 7];
560
- var controlDigit = parseInt(bban.charAt(7), 10);
561
- var toCheck = bban.substring(0, 7);
562
- var sum = 0;
563
- for (var index = 0; index < 7; index++) {
556
+ const checkPolandBBAN = (bban) => {
557
+ const weights = [3, 9, 7, 1, 3, 9, 7];
558
+ const controlDigit = parseInt(bban.charAt(7), 10);
559
+ const toCheck = bban.substring(0, 7);
560
+ let sum = 0;
561
+ for (let index = 0; index < 7; index++) {
564
562
  sum += parseInt(toCheck.charAt(index), 10) * weights[index];
565
563
  }
566
- var remainder = sum % 10;
564
+ const remainder = sum % 10;
567
565
  return controlDigit === (remainder === 0 ? 0 : 10 - remainder);
568
566
  };
569
567
  /**
@@ -571,23 +569,23 @@ var checkPolandBBAN = function (bban) {
571
569
  *
572
570
  * @ignore
573
571
  */
574
- var checkSpainBBAN = function (bban) {
575
- var weightsBankBranch = [4, 8, 5, 10, 9, 7, 3, 6];
576
- var weightsAccount = [1, 2, 4, 8, 5, 10, 9, 7, 3, 6];
577
- var controlBankBranch = parseInt(bban.charAt(8), 10);
578
- var controlAccount = parseInt(bban.charAt(9), 10);
579
- var bankBranch = bban.substring(0, 8);
580
- var account = bban.substring(10, 20);
581
- var sum = 0;
582
- for (var index = 0; index < 8; index++) {
572
+ const checkSpainBBAN = (bban) => {
573
+ const weightsBankBranch = [4, 8, 5, 10, 9, 7, 3, 6];
574
+ const weightsAccount = [1, 2, 4, 8, 5, 10, 9, 7, 3, 6];
575
+ const controlBankBranch = parseInt(bban.charAt(8), 10);
576
+ const controlAccount = parseInt(bban.charAt(9), 10);
577
+ const bankBranch = bban.substring(0, 8);
578
+ const account = bban.substring(10, 20);
579
+ let sum = 0;
580
+ for (let index = 0; index < 8; index++) {
583
581
  sum += parseInt(bankBranch.charAt(index), 10) * weightsBankBranch[index];
584
582
  }
585
- var remainder = sum % 11;
583
+ let remainder = sum % 11;
586
584
  if (controlBankBranch !== (remainder === 0 ? 0 : remainder === 1 ? 1 : 11 - remainder)) {
587
585
  return false;
588
586
  }
589
587
  sum = 0;
590
- for (var index = 0; index < 10; index++) {
588
+ for (let index = 0; index < 10; index++) {
591
589
  sum += parseInt(account.charAt(index), 10) * weightsAccount[index];
592
590
  }
593
591
  remainder = sum % 11;
@@ -598,9 +596,9 @@ var checkSpainBBAN = function (bban) {
598
596
  *
599
597
  * @ignore
600
598
  */
601
- var checkMod1110 = function (toCheck, control) {
602
- var nr = 10;
603
- for (var index = 0; index < toCheck.length; index++) {
599
+ const checkMod1110 = (toCheck, control) => {
600
+ let nr = 10;
601
+ for (let index = 0; index < toCheck.length; index++) {
604
602
  nr += parseInt(toCheck.charAt(index), 10);
605
603
  if (nr % 10 !== 0) {
606
604
  nr = nr % 10;
@@ -615,11 +613,11 @@ var checkMod1110 = function (toCheck, control) {
615
613
  *
616
614
  * @ignore
617
615
  */
618
- var checkCroatianBBAN = function (bban) {
619
- var controlBankBranch = parseInt(bban.charAt(6), 10);
620
- var controlAccount = parseInt(bban.charAt(16), 10);
621
- var bankBranch = bban.substring(0, 6);
622
- var account = bban.substring(7, 16);
616
+ const checkCroatianBBAN = (bban) => {
617
+ const controlBankBranch = parseInt(bban.charAt(6), 10);
618
+ const controlAccount = parseInt(bban.charAt(16), 10);
619
+ const bankBranch = bban.substring(0, 6);
620
+ const account = bban.substring(7, 16);
623
621
  return checkMod1110(bankBranch, controlBankBranch) && checkMod1110(account, controlAccount);
624
622
  };
625
623
  /**
@@ -627,23 +625,23 @@ var checkCroatianBBAN = function (bban) {
627
625
  *
628
626
  * @ignore
629
627
  */
630
- var checkCzechAndSlovakBBAN = function (bban) {
631
- var weightsPrefix = [10, 5, 8, 4, 2, 1];
632
- var weightsSuffix = [6, 3, 7, 9, 10, 5, 8, 4, 2, 1];
633
- var controlPrefix = parseInt(bban.charAt(9), 10);
634
- var controlSuffix = parseInt(bban.charAt(19), 10);
635
- var prefix = bban.substring(4, 9);
636
- var suffix = bban.substring(10, 19);
637
- var sum = 0;
638
- for (var index = 0; index < prefix.length; index++) {
628
+ const checkCzechAndSlovakBBAN = (bban) => {
629
+ const weightsPrefix = [10, 5, 8, 4, 2, 1];
630
+ const weightsSuffix = [6, 3, 7, 9, 10, 5, 8, 4, 2, 1];
631
+ const controlPrefix = parseInt(bban.charAt(9), 10);
632
+ const controlSuffix = parseInt(bban.charAt(19), 10);
633
+ const prefix = bban.substring(4, 9);
634
+ const suffix = bban.substring(10, 19);
635
+ let sum = 0;
636
+ for (let index = 0; index < prefix.length; index++) {
639
637
  sum += parseInt(prefix.charAt(index), 10) * weightsPrefix[index];
640
638
  }
641
- var remainder = sum % 11;
639
+ let remainder = sum % 11;
642
640
  if (controlPrefix !== (remainder === 0 ? 0 : remainder === 1 ? 1 : 11 - remainder)) {
643
641
  return false;
644
642
  }
645
643
  sum = 0;
646
- for (var index = 0; index < suffix.length; index++) {
644
+ for (let index = 0; index < suffix.length; index++) {
647
645
  sum += parseInt(suffix.charAt(index), 10) * weightsSuffix[index];
648
646
  }
649
647
  remainder = sum % 11;
@@ -654,15 +652,15 @@ var checkCzechAndSlovakBBAN = function (bban) {
654
652
  *
655
653
  * @ignore
656
654
  */
657
- var checkEstonianBBAN = function (bban) {
658
- var weights = [7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1, 3, 7];
659
- var controlDigit = parseInt(bban.charAt(15), 10);
660
- var toCheck = bban.substring(2, 15);
661
- var sum = 0;
662
- for (var index = 0; index < toCheck.length; index++) {
655
+ const checkEstonianBBAN = (bban) => {
656
+ const weights = [7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1, 3, 7];
657
+ const controlDigit = parseInt(bban.charAt(15), 10);
658
+ const toCheck = bban.substring(2, 15);
659
+ let sum = 0;
660
+ for (let index = 0; index < toCheck.length; index++) {
663
661
  sum += parseInt(toCheck.charAt(index), 10) * weights[index];
664
662
  }
665
- var remainder = sum % 10;
663
+ const remainder = sum % 10;
666
664
  return controlDigit === (remainder === 0 ? 0 : 10 - remainder);
667
665
  };
668
666
  /**
@@ -671,11 +669,11 @@ var checkEstonianBBAN = function (bban) {
671
669
  *
672
670
  * @ignore
673
671
  */
674
- var checkFrenchBBAN = function (bban) {
675
- var stripped = bban.replace(/[\s.]+/g, '');
676
- var normalized = Array.from(stripped);
677
- for (var index = 0; index < stripped.length; index++) {
678
- var c = normalized[index].charCodeAt(0);
672
+ const checkFrenchBBAN = (bban) => {
673
+ const stripped = bban.replace(/[\s.]+/g, '');
674
+ const normalized = Array.from(stripped);
675
+ for (let index = 0; index < stripped.length; index++) {
676
+ const c = normalized[index].charCodeAt(0);
679
677
  if (c >= 65) {
680
678
  switch (c) {
681
679
  case 65:
@@ -725,7 +723,7 @@ var checkFrenchBBAN = function (bban) {
725
723
  }
726
724
  }
727
725
  }
728
- var remainder = mod9710(normalized.join(''));
726
+ const remainder = mod9710(normalized.join(''));
729
727
  return remainder === 0;
730
728
  };
731
729
  /**
@@ -733,36 +731,36 @@ var checkFrenchBBAN = function (bban) {
733
731
  *
734
732
  * @ignore
735
733
  */
736
- var checkHungarianBBAN = function (bban) {
737
- var weights = [9, 7, 3, 1, 9, 7, 3, 1, 9, 7, 3, 1, 9, 7, 3];
738
- var controlDigitBankBranch = parseInt(bban.charAt(7), 10);
739
- var toCheckBankBranch = bban.substring(0, 7);
740
- var sum = 0;
741
- for (var index = 0; index < toCheckBankBranch.length; index++) {
734
+ const checkHungarianBBAN = (bban) => {
735
+ const weights = [9, 7, 3, 1, 9, 7, 3, 1, 9, 7, 3, 1, 9, 7, 3];
736
+ const controlDigitBankBranch = parseInt(bban.charAt(7), 10);
737
+ const toCheckBankBranch = bban.substring(0, 7);
738
+ let sum = 0;
739
+ for (let index = 0; index < toCheckBankBranch.length; index++) {
742
740
  sum += parseInt(toCheckBankBranch.charAt(index), 10) * weights[index];
743
741
  }
744
- var remainder = sum % 10;
742
+ const remainder = sum % 10;
745
743
  if (controlDigitBankBranch !== (remainder === 0 ? 0 : 10 - remainder)) {
746
744
  return false;
747
745
  }
748
746
  sum = 0;
749
747
  if (bban.endsWith('00000000')) {
750
- var toCheckAccount = bban.substring(8, 15);
751
- var controlDigitAccount = parseInt(bban.charAt(15), 10);
752
- for (var index = 0; index < toCheckAccount.length; index++) {
748
+ const toCheckAccount = bban.substring(8, 15);
749
+ const controlDigitAccount = parseInt(bban.charAt(15), 10);
750
+ for (let index = 0; index < toCheckAccount.length; index++) {
753
751
  sum += parseInt(toCheckAccount.charAt(index), 10) * weights[index];
754
752
  }
755
- var remainder_1 = sum % 10;
756
- return controlDigitAccount === (remainder_1 === 0 ? 0 : 10 - remainder_1);
753
+ const remainder = sum % 10;
754
+ return controlDigitAccount === (remainder === 0 ? 0 : 10 - remainder);
757
755
  }
758
756
  else {
759
- var toCheckAccount = bban.substring(8, 23);
760
- var controlDigitAccount = parseInt(bban.charAt(23), 10);
761
- for (var index = 0; index < toCheckAccount.length; index++) {
757
+ const toCheckAccount = bban.substring(8, 23);
758
+ const controlDigitAccount = parseInt(bban.charAt(23), 10);
759
+ for (let index = 0; index < toCheckAccount.length; index++) {
762
760
  sum += parseInt(toCheckAccount.charAt(index), 10) * weights[index];
763
761
  }
764
- var remainder_2 = sum % 10;
765
- return controlDigitAccount === (remainder_2 === 0 ? 0 : 10 - remainder_2);
762
+ const remainder = sum % 10;
763
+ return controlDigitAccount === (remainder === 0 ? 0 : 10 - remainder);
766
764
  }
767
765
  };
768
766
  /**
@@ -771,7 +769,7 @@ var checkHungarianBBAN = function (bban) {
771
769
  * If `bban_validation_func` already exists for the corresponding country,
772
770
  * it will be overwritten.
773
771
  */
774
- export var setCountryBBANValidation = function (country, func) {
772
+ export const setCountryBBANValidation = (country, func) => {
775
773
  if (typeof countrySpecs[country] === 'undefined') {
776
774
  return false;
777
775
  }
@@ -781,7 +779,7 @@ export var setCountryBBANValidation = function (country, func) {
781
779
  /**
782
780
  * Country specifications
783
781
  */
784
- export var countrySpecs = {
782
+ export const countrySpecs = {
785
783
  AD: {
786
784
  chars: 24,
787
785
  bban_regexp: '^[0-9]{8}[A-Z0-9]{12}$',
@@ -972,7 +970,7 @@ export var countrySpecs = {
972
970
  IBANRegistry: true,
973
971
  SEPA: true,
974
972
  bank_identifier: '0-7',
975
- account_indentifier: '13-22',
973
+ account_indentifier: '12-22',
976
974
  },
977
975
  DJ: {
978
976
  chars: 27,
@@ -1029,7 +1027,7 @@ export var countrySpecs = {
1029
1027
  SEPA: true,
1030
1028
  branch_indentifier: '4-7',
1031
1029
  bank_identifier: '0-3',
1032
- account_indentifier: '4-24',
1030
+ account_indentifier: '14-24',
1033
1031
  },
1034
1032
  ET: {},
1035
1033
  FI: {
@@ -1436,7 +1434,13 @@ export var countrySpecs = {
1436
1434
  NR: {},
1437
1435
  NU: {},
1438
1436
  NZ: {},
1439
- OM: {},
1437
+ OM: {
1438
+ chars: 23,
1439
+ bban_regexp: '^[0-9]{3}[A-Z0-9]{16}$',
1440
+ IBANRegistry: true,
1441
+ SEPA: false,
1442
+ bank_identifier: '0-2',
1443
+ },
1440
1444
  PA: {},
1441
1445
  PE: {},
1442
1446
  PF: {