forgot password in login page and account info implemented, sms.ir service works fine with sandbox key.
This commit is contained in:
20
backend/src/common/utils/mobile.util.ts
Normal file
20
backend/src/common/utils/mobile.util.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
const IRAN_MOBILE_PATTERN = /^9\d{9}$/;
|
||||
|
||||
/** Normalize Iranian mobile to sms.ir format (e.g. 9123456789). */
|
||||
export function normalizeIranMobile(input: string): string {
|
||||
let digits = input.replace(/\D/g, '');
|
||||
|
||||
if (digits.startsWith('98') && digits.length === 12) {
|
||||
digits = digits.slice(2);
|
||||
}
|
||||
|
||||
if (digits.startsWith('0') && digits.length === 11) {
|
||||
digits = digits.slice(1);
|
||||
}
|
||||
|
||||
return digits;
|
||||
}
|
||||
|
||||
export function isValidIranMobile(input: string): boolean {
|
||||
return IRAN_MOBILE_PATTERN.test(normalizeIranMobile(input));
|
||||
}
|
||||
Reference in New Issue
Block a user