@medipass/utils 11.75.2 → 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/CHANGELOG.md +11 -0
- package/constants.d.ts +1 -0
- package/constants.js +2 -1
- package/package.json +2 -2
- package/validate-form.d.ts +17 -17
- package/validate-form.js +15 -32
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [11.76.0](https://github.com/medipass/web-medicules/compare/@medipass/utils@11.75.2...@medipass/utils@11.76.0) (2023-02-23)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **sdk:** futures ([#748](https://github.com/medipass/web-medicules/issues/748)) ([58b7d62](https://github.com/medipass/web-medicules/commit/58b7d62))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [11.75.2](https://github.com/medipass/web-medicules/compare/@medipass/utils@11.75.1...@medipass/utils@11.75.2) (2023-02-20)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @medipass/utils
|
package/constants.d.ts
CHANGED
|
@@ -203,6 +203,7 @@ export declare const TRANSACTION_PAYMENT_OPTIONS: {
|
|
|
203
203
|
export declare const TRANSACTION_PLATFORM: {
|
|
204
204
|
readonly FUNDER: "funder";
|
|
205
205
|
readonly VIRTUAL_TERMINAL: "virtual-terminal";
|
|
206
|
+
readonly FUTURES: "futures";
|
|
206
207
|
};
|
|
207
208
|
export declare const TRANSACTION_STATUSES: {
|
|
208
209
|
readonly DISABLED: "disabled";
|
package/constants.js
CHANGED
|
@@ -248,7 +248,8 @@ var TRANSACTION_PAYMENT_OPTIONS = {
|
|
|
248
248
|
};
|
|
249
249
|
var TRANSACTION_PLATFORM = {
|
|
250
250
|
FUNDER: 'funder',
|
|
251
|
-
VIRTUAL_TERMINAL: 'virtual-terminal'
|
|
251
|
+
VIRTUAL_TERMINAL: 'virtual-terminal',
|
|
252
|
+
FUTURES: 'futures'
|
|
252
253
|
};
|
|
253
254
|
var TRANSACTION_STATUSES = {
|
|
254
255
|
DISABLED: 'disabled',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medipass/utils",
|
|
3
|
-
"version": "11.
|
|
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": "
|
|
54
|
+
"gitHead": "0375f57fcfbe7a12ab2f637bc50bd477968b65cb"
|
|
55
55
|
}
|
package/validate-form.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export declare const isRequired: (value:
|
|
2
|
-
export declare const isNumber: (value:
|
|
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:
|
|
14
|
-
export declare const hasNumber: (value:
|
|
15
|
-
export declare const isValidBankAccountName: (value:
|
|
16
|
-
export declare const hasSpecialChar: (value:
|
|
17
|
-
export declare const isValidEmailAsync: (value:
|
|
18
|
-
export declare const isValidEmail: (value:
|
|
19
|
-
export declare const isValidMobile: (value:
|
|
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:
|
|
45
|
-
export declare const matchesRegex: (pattern:
|
|
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:
|
|
51
|
-
export declare const hasWhitespaceAtStartOrEnd: (value:
|
|
52
|
-
export declare const hasSpaceAfterHyphen: (value:
|
|
53
|
-
export declare const hasSpaceBeforeHyphen: (value:
|
|
54
|
-
export declare const hasSpaceAfterApostrophe: (value:
|
|
55
|
-
export declare const hasSpaceBeforeApostrophe: (value:
|
|
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
|
-
};
|
|
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
|
-
};
|
|
108
|
-
|
|
106
|
+
};
|
|
109
107
|
var hasUppercaseLetter = function hasUppercaseLetter(value) {
|
|
110
108
|
return /[A-Z]/.test(value) ? undefined : 'Field must contain an uppercase letter';
|
|
111
|
-
};
|
|
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
|
-
};
|
|
121
|
-
|
|
116
|
+
};
|
|
122
117
|
var hasSpecialChar = function hasSpecialChar(value) {
|
|
123
118
|
return /[!@?#$%^&*)(+=._-]/.test(value) ? undefined : 'Field must contain a special character (e.g. !@#)';
|
|
124
|
-
};
|
|
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
|
-
}();
|
|
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
|
-
};
|
|
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
|
-
};
|
|
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
|
-
};
|
|
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
|
-
};
|
|
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
|
-
};
|
|
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
|
-
};
|
|
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
|
-
};
|
|
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
|
-
};
|
|
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
|
-
};
|
|
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
|
};
|