ibantools 4.3.6 → 4.3.7

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.
Files changed (2) hide show
  1. package/build/ibantools.js +33 -1
  2. package/package.json +2 -2
@@ -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.7
12
12
  * @license MPL-2.0
13
13
  * @preferred
14
14
  */
@@ -776,6 +776,37 @@ var checkHungarianBBAN = function (bban) {
776
776
  return controlDigitAccount === (remainder_2 === 0 ? 0 : 10 - remainder_2);
777
777
  }
778
778
  };
779
+ /**
780
+ * Dutch (NL) BBAN check
781
+ *
782
+ * @ignore
783
+ */
784
+ var checkDutchBBAN = function (bban) {
785
+ if (bban === '') {
786
+ return false;
787
+ }
788
+ var weights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1];
789
+ var toCheckAccount = bban.substring(4, 14);
790
+ if (toCheckAccount.startsWith('000')) {
791
+ return true;
792
+ }
793
+ if (toCheckAccount.startsWith('00')) {
794
+ return false;
795
+ }
796
+ var sum = toCheckAccount
797
+ .split('')
798
+ .map(function (value, index) {
799
+ if (value === '0' && index === 0) {
800
+ return 0;
801
+ }
802
+ var number = parseInt(value, 10);
803
+ var weight = weights[index];
804
+ return number * weight;
805
+ })
806
+ .reduce(function (a, b) { return a + b; });
807
+ console.log(sum);
808
+ return sum % 11 === 0;
809
+ };
779
810
  /**
780
811
  * Set custom BBAN validation function for country.
781
812
  *
@@ -1429,6 +1460,7 @@ exports.countrySpecs = {
1429
1460
  NL: {
1430
1461
  chars: 18,
1431
1462
  bban_regexp: '^[A-Z]{4}[0-9]{10}$',
1463
+ bban_validation_func: checkDutchBBAN,
1432
1464
  IBANRegistry: true,
1433
1465
  SEPA: true,
1434
1466
  bank_identifier: '0-3',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ibantools",
3
- "version": "4.3.6",
3
+ "version": "4.3.7",
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",
@@ -74,7 +74,7 @@
74
74
  "prettier": "^3.0.3",
75
75
  "requirejs": "^2.3.6",
76
76
  "typedoc": "^0.25.1",
77
- "typescript": "^5.2.2"
77
+ "typescript": "^5.2"
78
78
  },
79
79
  "resolutions": {
80
80
  "source-map": "^0.8.0-beta.0"