@medipass/utils 11.76.0 → 11.76.1-chore-add-typescript-support-validations.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medipass/utils",
3
- "version": "11.76.0",
3
+ "version": "11.76.1-chore-add-typescript-support-validations.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -51,5 +51,5 @@
51
51
  "rimraf": "^2.6.2",
52
52
  "typescript": "4.8.4"
53
53
  },
54
- "gitHead": "8713fcbef4afd57c4a7bc63a77f25a8ad8d82ae2"
54
+ "gitHead": "0375f57fcfbe7a12ab2f637bc50bd477968b65cb"
55
55
  }
@@ -1,5 +1,5 @@
1
- export declare const isRequired: (value: any) => "This field is required" | undefined;
2
- export declare const isNumber: (value: any) => "This field must only contain numbers" | undefined;
1
+ export declare const isRequired: (value: string) => "This field is required" | undefined;
2
+ export declare const isNumber: (value: string) => "This field must only contain numbers" | undefined;
3
3
  export declare const isEqualTo: (target: any, message?: string) => (value: any) => string | undefined;
4
4
  export declare const isSameValueAsField: (targetField: any, message?: string) => (value: any, values: any) => string | undefined;
5
5
  export declare const isLengthEqualTo: (length: any, message?: string) => (value: any) => string | undefined;
@@ -10,13 +10,13 @@ export declare const isLengthWithSpacesGreaterThanOrEqualTo: (length: any) => (v
10
10
  export declare const isGreaterThanOrEqualTo: (length: any) => (value: any) => string | undefined;
11
11
  export declare const isGreaterThan: (length: any) => (value: any) => string | undefined;
12
12
  export declare const isLessThanOrEqualTo: (length: any) => (value: any) => string | undefined;
13
- export declare const hasUppercaseLetter: (value: any) => "Field must contain an uppercase letter" | undefined;
14
- export declare const hasNumber: (value: any) => "Field must contain a number" | undefined;
15
- export declare const isValidBankAccountName: (value: any) => "Bank account name must not contain any special characters" | undefined;
16
- export declare const hasSpecialChar: (value: any) => "Field must contain a special character (e.g. !@#)" | undefined;
17
- export declare const isValidEmailAsync: (value: any) => Promise<"Please enter a valid email" | undefined>;
18
- export declare const isValidEmail: (value: any) => "Please enter a valid email" | undefined;
19
- export declare const isValidMobile: (value: any) => "Please enter a valid mobile number" | undefined;
13
+ export declare const hasUppercaseLetter: (value: string) => "Field must contain an uppercase letter" | undefined;
14
+ export declare const hasNumber: (value: string) => "Field must contain a number" | undefined;
15
+ export declare const isValidBankAccountName: (value: string) => "Bank account name must not contain any special characters" | undefined;
16
+ export declare const hasSpecialChar: (value: string) => "Field must contain a special character (e.g. !@#)" | undefined;
17
+ export declare const isValidEmailAsync: (value: string) => Promise<"Please enter a valid email" | undefined>;
18
+ export declare const isValidEmail: (value: string) => "Please enter a valid email" | undefined;
19
+ export declare const isValidMobile: (value: string) => "Please enter a valid mobile number" | undefined;
20
20
  export declare const isValidDatePatterns: ({ day, month, year }: {
21
21
  day?: {
22
22
  message: string;
@@ -41,18 +41,18 @@ export declare const isYearInRange: ({ index, isShortYearFormat, lessThanCurrent
41
41
  isShortYearFormat?: boolean | undefined;
42
42
  lessThanCurrentYear?: boolean | undefined;
43
43
  }) => (value?: string) => string | undefined;
44
- export declare const isValidDOB: (value: any) => "Date is invalid" | "Year must be before current year." | "Year must be greater than 1900" | undefined;
45
- export declare const matchesRegex: (pattern: any, message: any) => (value: any) => any;
44
+ export declare const isValidDOB: (value: string) => "Date is invalid" | "Year must be before current year." | "Year must be greater than 1900" | undefined;
45
+ export declare const matchesRegex: (pattern: string, message: string) => (value: string) => string | undefined;
46
46
  export declare const isFutureDate: (value: any) => "Date must not be in the future." | undefined;
47
47
  export declare const isMoreThanThreeYears: (value: any) => "Date must not be more than 3 years ago." | undefined;
48
48
  export declare const hasInvalidCharacters: (value: any) => "This field cannot contain ( or )" | undefined;
49
49
  export declare const hasStrictInvalidCharacters: (value: any) => "This field cannot contain any special characters except for space, hyphen and apostrophe under certain conditions" | undefined;
50
- export declare const hasDoubleSpaces: (value: any) => "There can be no double spaces in the supplied value" | undefined;
51
- export declare const hasWhitespaceAtStartOrEnd: (value: any) => "There can be no spaces at the start or end of the supplied value" | undefined;
52
- export declare const hasSpaceAfterHyphen: (value: any) => "Name cannot have a space after a hyphen (-)" | undefined;
53
- export declare const hasSpaceBeforeHyphen: (value: any) => "Name cannot have a space before a hyphen (-)" | undefined;
54
- export declare const hasSpaceAfterApostrophe: (value: any) => "Name cannot have a space after an apostrophe (')" | undefined;
55
- export declare const hasSpaceBeforeApostrophe: (value: any) => "Name cannot have a space before an apostrophe (')" | undefined;
50
+ export declare const hasDoubleSpaces: (value: string) => "There can be no double spaces in the supplied value" | undefined;
51
+ export declare const hasWhitespaceAtStartOrEnd: (value: string) => "There can be no spaces at the start or end of the supplied value" | undefined;
52
+ export declare const hasSpaceAfterHyphen: (value: string) => "Name cannot have a space after a hyphen (-)" | undefined;
53
+ export declare const hasSpaceBeforeHyphen: (value: string) => "Name cannot have a space before a hyphen (-)" | undefined;
54
+ export declare const hasSpaceAfterApostrophe: (value: string) => "Name cannot have a space after an apostrophe (')" | undefined;
55
+ export declare const hasSpaceBeforeApostrophe: (value: string) => "Name cannot have a space before an apostrophe (')" | undefined;
56
56
  export declare const isValidAbn: (value: string) => "Invalid ABN" | undefined;
57
57
  export declare const isValidAcn: (value: string) => "Invalid ACN" | undefined;
58
58
  export declare const isValidAbnOrAcn: (value: string) => "Invalid ABN or ACN" | undefined;
package/validate-form.js CHANGED
@@ -22,8 +22,7 @@ var abn = require('./abn.js');
22
22
 
23
23
  var isRequired = function isRequired(value) {
24
24
  return !value || value.trim && !value.trim() || _isArray(value) && value.length === 0 ? 'This field is required' : undefined;
25
- }; // @ts-expect-error TS(7006): Parameter 'value' implicitly has an 'any' type.
26
-
25
+ };
27
26
  var isNumber = function isNumber(value) {
28
27
  return value && value.match(/[^0-9]/) ? 'This field must only contain numbers' : undefined;
29
28
  };
@@ -104,26 +103,20 @@ var isLessThanOrEqualTo = function isLessThanOrEqualTo(length) {
104
103
  return function (value) {
105
104
  return !value || parseFloat(value) <= length ? undefined : "Must be less than or equal to " + length;
106
105
  };
107
- }; // @ts-expect-error TS(7006): Parameter 'value' implicitly has an 'any' type.
108
-
106
+ };
109
107
  var hasUppercaseLetter = function hasUppercaseLetter(value) {
110
108
  return /[A-Z]/.test(value) ? undefined : 'Field must contain an uppercase letter';
111
- }; // @ts-expect-error TS(7006): Parameter 'value' implicitly has an 'any' type.
112
-
109
+ };
113
110
  var hasNumber = function hasNumber(value) {
114
111
  return /[0-9]/.test(value) ? undefined : 'Field must contain a number';
115
112
  }; // Adheres to the 'BECS EBCDIC' character set.
116
- // @ts-expect-error TS(7006): Parameter 'value' implicitly has an 'any' type.
117
113
 
118
114
  var isValidBankAccountName = function isValidBankAccountName(value) {
119
115
  return /^[A-Za-z0-9^_[\]',?;:=#/.*()&%!$ @+-]+$/.test(value) ? undefined : 'Bank account name must not contain any special characters';
120
- }; // @ts-expect-error TS(7006): Parameter 'value' implicitly has an 'any' type.
121
-
116
+ };
122
117
  var hasSpecialChar = function hasSpecialChar(value) {
123
118
  return /[!@?#$%^&*)(+=._-]/.test(value) ? undefined : 'Field must contain a special character (e.g. !@#)';
124
- }; // @ts-expect-error TS(7006): Parameter 'value' implicitly has an 'any' type.
125
- // eslint-disable-line no-useless-escape
126
-
119
+ };
127
120
  var isValidEmailAsync = /*#__PURE__*/function () {
128
121
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(value) {
129
122
  return _regeneratorRuntime.wrap(function _callee$(_context) {
@@ -170,12 +163,10 @@ var isValidEmailAsync = /*#__PURE__*/function () {
170
163
  return function isValidEmailAsync(_x) {
171
164
  return _ref.apply(this, arguments);
172
165
  };
173
- }(); // @ts-expect-error TS(7006): Parameter 'value' implicitly has an 'any' type.
174
-
166
+ }();
175
167
  var isValidEmail = function isValidEmail(value) {
176
168
  return !value || /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]+$/i.test(value) ? undefined : 'Please enter a valid email';
177
- }; // @ts-expect-error TS(7006): Parameter 'value' implicitly has an 'any' type.
178
-
169
+ };
179
170
  var isValidMobile = function isValidMobile(value) {
180
171
  return !value || validate.isMobileNumber(value, 'AU') ? undefined : 'Please enter a valid mobile number';
181
172
  };
@@ -303,8 +294,7 @@ var isYearInRange = function isYearInRange(_ref4) {
303
294
 
304
295
  return undefined;
305
296
  };
306
- }; // @ts-expect-error TS(7006): Parameter 'value' implicitly has an 'any' type.
307
-
297
+ };
308
298
  var isValidDOB = function isValidDOB(value) {
309
299
  var invalidDate = isValidDate(value);
310
300
  if (invalidDate) return invalidDate;
@@ -320,8 +310,7 @@ var isValidDOB = function isValidDOB(value) {
320
310
  }
321
311
 
322
312
  return undefined;
323
- }; // @ts-expect-error TS(7006): Parameter 'pattern' implicitly has an 'any' type.
324
-
313
+ };
325
314
  var matchesRegex = function matchesRegex(pattern, message) {
326
315
  return function (value) {
327
316
  return !value || new RegExp(pattern).test(value) ? undefined : message;
@@ -345,28 +334,22 @@ var hasInvalidCharacters = function hasInvalidCharacters(value) {
345
334
 
346
335
  var hasStrictInvalidCharacters = function hasStrictInvalidCharacters(value) {
347
336
  return value && /[^A-Za-z0-9-' ]/.test(value) ? 'This field cannot contain any special characters except for space, hyphen and apostrophe under certain conditions' : undefined;
348
- }; // @ts-expect-error TS(7006): Parameter 'value' implicitly has an 'any' type.
349
-
337
+ };
350
338
  var hasDoubleSpaces = function hasDoubleSpaces(value) {
351
339
  return value && /\s\s+/g.test(value) ? 'There can be no double spaces in the supplied value' : undefined;
352
- }; // @ts-expect-error TS(7006): Parameter 'value' implicitly has an 'any' type.
353
-
340
+ };
354
341
  var hasWhitespaceAtStartOrEnd = function hasWhitespaceAtStartOrEnd(value) {
355
342
  return value && /(^\s+)|(\s+$)/.test(value) ? 'There can be no spaces at the start or end of the supplied value' : undefined;
356
- }; // @ts-expect-error TS(7006): Parameter 'value' implicitly has an 'any' type.
357
-
343
+ };
358
344
  var hasSpaceAfterHyphen = function hasSpaceAfterHyphen(value) {
359
345
  return value && /([-]\s)/.test(value) ? 'Name cannot have a space after a hyphen (-)' : undefined;
360
- }; // @ts-expect-error TS(7006): Parameter 'value' implicitly has an 'any' type.
361
-
346
+ };
362
347
  var hasSpaceBeforeHyphen = function hasSpaceBeforeHyphen(value) {
363
348
  return value && /(\s[-])/.test(value) ? 'Name cannot have a space before a hyphen (-)' : undefined;
364
- }; // @ts-expect-error TS(7006): Parameter 'value' implicitly has an 'any' type.
365
-
349
+ };
366
350
  var hasSpaceAfterApostrophe = function hasSpaceAfterApostrophe(value) {
367
351
  return value && /([']\s)/.test(value) ? "Name cannot have a space after an apostrophe (')" : undefined;
368
- }; // @ts-expect-error TS(7006): Parameter 'value' implicitly has an 'any' type.
369
-
352
+ };
370
353
  var hasSpaceBeforeApostrophe = function hasSpaceBeforeApostrophe(value) {
371
354
  return value && /(\s['])/.test(value) ? "Name cannot have a space before an apostrophe (')" : undefined;
372
355
  };