ibantools 4.3.7 → 4.3.8

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.
@@ -8,7 +8,7 @@
8
8
  * @package Documentation
9
9
  * @author Saša Jovanić
10
10
  * @module ibantools
11
- * @version 4.3.7
11
+ * @version 4.3.8
12
12
  * @license MPL-2.0
13
13
  * @preferred
14
14
  */
@@ -804,7 +804,6 @@ var checkDutchBBAN = function (bban) {
804
804
  return number * weight;
805
805
  })
806
806
  .reduce(function (a, b) { return a + b; });
807
- console.log(sum);
808
807
  return sum % 11 === 0;
809
808
  };
810
809
  /**
@@ -8,7 +8,7 @@
8
8
  * @package Documentation
9
9
  * @author Saša Jovanić
10
10
  * @module ibantools
11
- * @version 4.3.6
11
+ * @version 4.3.8
12
12
  * @license MPL-2.0
13
13
  * @preferred
14
14
  */
@@ -761,6 +761,36 @@ var checkHungarianBBAN = function (bban) {
761
761
  return controlDigitAccount === (remainder_2 === 0 ? 0 : 10 - remainder_2);
762
762
  }
763
763
  };
764
+ /**
765
+ * Dutch (NL) BBAN check
766
+ *
767
+ * @ignore
768
+ */
769
+ var checkDutchBBAN = function (bban) {
770
+ if (bban === '') {
771
+ return false;
772
+ }
773
+ var weights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1];
774
+ var toCheckAccount = bban.substring(4, 14);
775
+ if (toCheckAccount.startsWith('000')) {
776
+ return true;
777
+ }
778
+ if (toCheckAccount.startsWith('00')) {
779
+ return false;
780
+ }
781
+ var sum = toCheckAccount
782
+ .split('')
783
+ .map(function (value, index) {
784
+ if (value === '0' && index === 0) {
785
+ return 0;
786
+ }
787
+ var number = parseInt(value, 10);
788
+ var weight = weights[index];
789
+ return number * weight;
790
+ })
791
+ .reduce(function (a, b) { return a + b; });
792
+ return sum % 11 === 0;
793
+ };
764
794
  /**
765
795
  * Set custom BBAN validation function for country.
766
796
  *
@@ -1413,6 +1443,7 @@ export var countrySpecs = {
1413
1443
  NL: {
1414
1444
  chars: 18,
1415
1445
  bban_regexp: '^[A-Z]{4}[0-9]{10}$',
1446
+ bban_validation_func: checkDutchBBAN,
1416
1447
  IBANRegistry: true,
1417
1448
  SEPA: true,
1418
1449
  bank_identifier: '0-3',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ibantools",
3
- "version": "4.3.7",
3
+ "version": "4.3.8",
4
4
  "description": "Validation, extraction and creation of IBAN, BBAN, BIC/SWIFT numbers plus some other helpful stuff like ISO 3136-1 alpha 2 country list",
5
5
  "keywords": [
6
6
  "IBAN",