@medipass/utils 11.79.6 → 11.79.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.
- package/index.d.ts +1 -0
- package/package.json +2 -2
- package/validate-form.d.ts +1 -0
- package/validate-form.js +4 -0
- package/validate.d.ts +2 -0
- package/validate.js +21 -1
package/index.d.ts
CHANGED
|
@@ -94,6 +94,7 @@ declare const utils: {
|
|
|
94
94
|
isStringLength: (length: any, value: any) => Promise<boolean>;
|
|
95
95
|
isUrl: (value: any) => Promise<boolean>;
|
|
96
96
|
isMobileNumber: (phoneNumber: string, countryCode: string) => boolean;
|
|
97
|
+
isLandlineNumber: (landline: string, countryCode: string) => boolean;
|
|
97
98
|
};
|
|
98
99
|
};
|
|
99
100
|
export default utils;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medipass/utils",
|
|
3
|
-
"version": "11.79.
|
|
3
|
+
"version": "11.79.7",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"rimraf": "^2.6.2",
|
|
53
53
|
"typescript": "4.8.4"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "308bba1acaea8bbb7c7d75c673b9cb3443b8c756"
|
|
56
56
|
}
|
package/validate-form.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export declare const hasSpecialChar: (value: any) => "Field must contain a speci
|
|
|
22
22
|
export declare const isValidEmailAsync: (value: any) => Promise<"Please enter a valid email" | undefined>;
|
|
23
23
|
export declare const isValidEmail: (value: any) => "Please enter a valid email" | undefined;
|
|
24
24
|
export declare const isValidMobile: (value: any) => "Please enter a valid mobile number" | undefined;
|
|
25
|
+
export declare const isValidLandline: (value: string | undefined) => "Please enter a valid landline number" | undefined;
|
|
25
26
|
export declare const isValidDatePatterns: ({ day, month, year }: {
|
|
26
27
|
day?: {
|
|
27
28
|
message: string;
|
package/validate-form.js
CHANGED
|
@@ -185,6 +185,9 @@ var isValidEmail = function isValidEmail(value) {
|
|
|
185
185
|
var isValidMobile = function isValidMobile(value) {
|
|
186
186
|
return !value || validate.isMobileNumber(value, 'AU') ? undefined : 'Please enter a valid mobile number';
|
|
187
187
|
};
|
|
188
|
+
var isValidLandline = function isValidLandline(value) {
|
|
189
|
+
return !value || validate.isLandlineNumber(value, 'AU') ? undefined : 'Please enter a valid landline number';
|
|
190
|
+
};
|
|
188
191
|
var isValidDatePatterns = function isValidDatePatterns(_ref2) {
|
|
189
192
|
var day = _ref2.day,
|
|
190
193
|
month = _ref2.month,
|
|
@@ -461,6 +464,7 @@ exports.isValidDate = isValidDate;
|
|
|
461
464
|
exports.isValidDatePatterns = isValidDatePatterns;
|
|
462
465
|
exports.isValidEmail = isValidEmail;
|
|
463
466
|
exports.isValidEmailAsync = isValidEmailAsync;
|
|
467
|
+
exports.isValidLandline = isValidLandline;
|
|
464
468
|
exports.isValidMobile = isValidMobile;
|
|
465
469
|
exports.isValidUrlAsync = isValidUrlAsync;
|
|
466
470
|
exports.isYearInRange = isYearInRange;
|
package/validate.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export declare const isNumber: (number: any) => Promise<boolean>;
|
|
|
6
6
|
export declare const isStringLength: (length: any, value: any) => Promise<boolean>;
|
|
7
7
|
export declare const isUrl: (value: any) => Promise<boolean>;
|
|
8
8
|
export declare const isMobileNumber: (phoneNumber: string, countryCode: string) => boolean;
|
|
9
|
+
export declare const isLandlineNumber: (landline: string, countryCode: string) => boolean;
|
|
9
10
|
declare const validate: {
|
|
10
11
|
isEmail: (email: any) => Promise<boolean>;
|
|
11
12
|
isNotEmpty: (value: any) => Promise<boolean>;
|
|
@@ -13,5 +14,6 @@ declare const validate: {
|
|
|
13
14
|
isStringLength: (length: any, value: any) => Promise<boolean>;
|
|
14
15
|
isUrl: (value: any) => Promise<boolean>;
|
|
15
16
|
isMobileNumber: (phoneNumber: string, countryCode: string) => boolean;
|
|
17
|
+
isLandlineNumber: (landline: string, countryCode: string) => boolean;
|
|
16
18
|
};
|
|
17
19
|
export default validate;
|
package/validate.js
CHANGED
|
@@ -46,17 +46,37 @@ var isMobileNumber = function isMobileNumber(phoneNumber, countryCode) {
|
|
|
46
46
|
return false;
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
+
var isLandlineNumber = function isLandlineNumber(landline, countryCode) {
|
|
50
|
+
if (!countryCode) {
|
|
51
|
+
throw new Error('`countryCode` not given.');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (!landline) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
var parsedPhoneNumber = phoneUtil.parse(landline, countryCode);
|
|
60
|
+
var numberType = phoneUtil.getNumberType(parsedPhoneNumber);
|
|
61
|
+
var isLandline = numberType === phoneType.FIXED_LINE || numberType === phoneType.TOLL_FREE || numberType === phoneType.SHARED_COST;
|
|
62
|
+
return isLandline;
|
|
63
|
+
} catch (err) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
49
67
|
var validate = {
|
|
50
68
|
isEmail: isEmail,
|
|
51
69
|
isNotEmpty: isNotEmpty,
|
|
52
70
|
isNumber: isNumber,
|
|
53
71
|
isStringLength: isStringLength,
|
|
54
72
|
isUrl: isUrl,
|
|
55
|
-
isMobileNumber: isMobileNumber
|
|
73
|
+
isMobileNumber: isMobileNumber,
|
|
74
|
+
isLandlineNumber: isLandlineNumber
|
|
56
75
|
};
|
|
57
76
|
|
|
58
77
|
exports.default = validate;
|
|
59
78
|
exports.isEmail = isEmail;
|
|
79
|
+
exports.isLandlineNumber = isLandlineNumber;
|
|
60
80
|
exports.isMobileNumber = isMobileNumber;
|
|
61
81
|
exports.isNotEmpty = isNotEmpty;
|
|
62
82
|
exports.isNumber = isNumber;
|