@medipass/utils 11.71.1-feature-abn-validators.0 → 11.71.1-feature-abn-validators.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.
package/abn.js CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var ABN_LENGTH = 11;
6
+ var ACN_LENGTH = 9;
7
+ var normaliseAbn = function normaliseAbn(abn) {
8
+ var trimmedABN = abn == null ? void 0 : abn.replace(/\s/g, ''); // The input is an ABN, in which case the format should be 99 999 999 999
9
+
10
+ if (trimmedABN.length === ABN_LENGTH) {
11
+ return trimmedABN.substring(0, 2) + ' ' + trimmedABN.substring(2, 5) + ' ' + trimmedABN.substring(5, 8) + ' ' + trimmedABN.substring(8);
12
+ } //The input is an ACN, in which case the format should be 999 999 999
13
+
14
+
15
+ if (trimmedABN.length === ACN_LENGTH) {
16
+ return trimmedABN.substring(0, 3) + ' ' + trimmedABN.substring(3, 6) + ' ' + trimmedABN.substring(6);
17
+ }
18
+
19
+ return abn;
20
+ };
5
21
  var isValidAbn = function isValidAbn(abn) {
6
22
  var VALID_ABN_LENGTH = 11; // strip whitespace from value
7
23
 
@@ -70,3 +86,4 @@ var isValidAcn = function isValidAcn(acn) {
70
86
 
71
87
  exports.isValidAbn = isValidAbn;
72
88
  exports.isValidAcn = isValidAcn;
89
+ exports.normaliseAbn = normaliseAbn;
@@ -0,0 +1 @@
1
+ export {};
package/lib/abn.d.ts CHANGED
@@ -1,2 +1,3 @@
1
+ export declare const normaliseAbn: (abn: string) => string;
1
2
  export declare const isValidAbn: (abn: string) => boolean;
2
3
  export declare const isValidAcn: (acn: string) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medipass/utils",
3
- "version": "11.71.1-feature-abn-validators.0",
3
+ "version": "11.71.1-feature-abn-validators.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
@@ -51,5 +51,5 @@
51
51
  "rimraf": "^2.6.2",
52
52
  "typescript": "4.8.4"
53
53
  },
54
- "gitHead": "63c6d536710da6ae0452f1f7b2a12038047ea516"
54
+ "gitHead": "b16c45ca45114d58aa4331800cfb659f151d2c19"
55
55
  }
@@ -1,2 +0,0 @@
1
- declare const _default: (abn: any) => any;
2
- export default _default;
package/normalise-abn.js DELETED
@@ -1,22 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var ABN_LENGTH = 11;
6
- var ACN_LENGTH = 9;
7
- var normaliseAbn = (function (abn) {
8
- var trimmedABN = abn && abn.replace(/\s/g, ''); // The input is an ABN, in which case the format should be 99 999 999 999
9
-
10
- if (trimmedABN.length === ABN_LENGTH) {
11
- return trimmedABN.substring(0, 2) + ' ' + trimmedABN.substring(2, 5) + ' ' + trimmedABN.substring(5, 8) + ' ' + trimmedABN.substring(8);
12
- } //The input is an ACN, in which case the format should be 999 999 999
13
-
14
-
15
- if (trimmedABN.length === ACN_LENGTH) {
16
- return trimmedABN.substring(0, 3) + ' ' + trimmedABN.substring(3, 6) + ' ' + trimmedABN.substring(6);
17
- }
18
-
19
- return abn;
20
- });
21
-
22
- exports.default = normaliseAbn;