Includes mobile auth, get_user/get_version, SMS wallet parity endpoints, appearance backfill, and related Prisma migrations. Co-authored-by: Cursor <cursoragent@cursor.com>
20 lines
609 B
TypeScript
20 lines
609 B
TypeScript
/** Normalize Iranian mobile to 09xxxxxxxxx, or null if invalid. */
|
|
export function normalizeMobile(input?: string | null): string | null {
|
|
if (!input) return null;
|
|
let digits = String(input).replace(/\D/g, '');
|
|
if (digits.startsWith('98') && digits.length >= 12) {
|
|
digits = `0${digits.slice(2)}`;
|
|
}
|
|
if (digits.startsWith('9') && digits.length === 10) {
|
|
digits = `0${digits}`;
|
|
}
|
|
if (!/^09\d{9}$/.test(digits)) {
|
|
return null;
|
|
}
|
|
return digits;
|
|
}
|
|
|
|
export function displayName(firstName: string, lastName: string) {
|
|
return `${firstName} ${lastName}`.replace(/\s+/g, ' ').trim();
|
|
}
|