fix: api tambah pengaduan jenna ai

This commit is contained in:
2025-12-01 11:21:38 +08:00
parent 4dd66dbd9a
commit ba0414a99c
2 changed files with 14 additions and 4 deletions

View File

@@ -1,6 +1,12 @@
export function isValidPhone(number: string): boolean {
const clean = number.replace(/[\s.-]/g, ""); // hapus spasi, titik, strip
const regex = /^(?:\+628|08)(\d{7,12})$/;
return regex.test(clean);
}
export function normalizePhoneNumber({ phone }: { phone: string }) {
// Hapus semua spasi, tanda hubung, atau karakter non-digit (+ tetap dipertahankan untuk dicek)
let cleaned = phone.trim().replace(/[\s-]/g, "");
let cleaned = phone.trim().replace(/[\s.-]/g, "");
// Jika diawali dengan +62 → ganti jadi 62
if (cleaned.startsWith("+62")) {