@takentrade/takentrade-libs 3.2.2 → 3.2.3
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.
|
@@ -47,7 +47,7 @@ export declare const isValidTransactionReference: (ref: string) => boolean;
|
|
|
47
47
|
* Sanitizes phone number to standard format
|
|
48
48
|
* Converts to: 2348012345678
|
|
49
49
|
*/
|
|
50
|
-
export declare const sanitizePhoneNumber: (phone: string) => string;
|
|
50
|
+
export declare const sanitizePhoneNumber: (phone: string, withPlus?: boolean) => string;
|
|
51
51
|
/**
|
|
52
52
|
* Validates date is not in the past
|
|
53
53
|
*/
|
|
@@ -66,10 +66,7 @@ const isStrongPassword = (password) => {
|
|
|
66
66
|
const hasUpperCase = /[A-Z]/.test(password);
|
|
67
67
|
const hasLowerCase = /[a-z]/.test(password);
|
|
68
68
|
const hasNumber = /\d/.test(password);
|
|
69
|
-
return (password.length >= minLength &&
|
|
70
|
-
hasUpperCase &&
|
|
71
|
-
hasLowerCase &&
|
|
72
|
-
hasNumber);
|
|
69
|
+
return (password.length >= minLength && hasUpperCase && hasLowerCase && hasNumber);
|
|
73
70
|
};
|
|
74
71
|
exports.isStrongPassword = isStrongPassword;
|
|
75
72
|
/**
|
|
@@ -91,19 +88,27 @@ exports.isValidTransactionReference = isValidTransactionReference;
|
|
|
91
88
|
* Sanitizes phone number to standard format
|
|
92
89
|
* Converts to: 2348012345678
|
|
93
90
|
*/
|
|
94
|
-
const sanitizePhoneNumber = (phone) => {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
91
|
+
const sanitizePhoneNumber = (phone, withPlus = false) => {
|
|
92
|
+
if (!phone)
|
|
93
|
+
return '';
|
|
94
|
+
const digits = phone.replace(/\D/g, '');
|
|
95
|
+
if (digits.startsWith('234') && digits.length >= 13) {
|
|
96
|
+
return withPlus ? '+' + digits : digits;
|
|
97
|
+
}
|
|
98
|
+
if (digits.startsWith('0') && digits.length === 11) {
|
|
99
|
+
const result = '234' + digits.substring(1);
|
|
100
|
+
return withPlus ? '+' + result : result;
|
|
101
|
+
}
|
|
102
|
+
if (digits.length === 10 && /^[789]/.test(digits)) {
|
|
103
|
+
const result = '234' + digits;
|
|
104
|
+
return withPlus ? '+' + result : result;
|
|
101
105
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
sanitized = '234' + sanitized;
|
|
106
|
+
if (digits.startsWith('234')) {
|
|
107
|
+
return withPlus ? '+' + digits : digits;
|
|
105
108
|
}
|
|
106
|
-
|
|
109
|
+
const cleaned = digits.replace(/^0+/, '').slice(0, 10);
|
|
110
|
+
const result = '234' + cleaned;
|
|
111
|
+
return withPlus ? '+' + result : result;
|
|
107
112
|
};
|
|
108
113
|
exports.sanitizePhoneNumber = sanitizePhoneNumber;
|
|
109
114
|
/**
|