feat: implement input length constraints and enhanced validation for international phone numbers

This commit is contained in:
estifanos
2026-08-20 08:58:07 +00:00
parent caa209306f
commit bc31cec0b2
5 changed files with 66 additions and 13 deletions

View File

@@ -1,3 +1,4 @@
import { isValidPhoneNumber } from 'libphonenumber-js';
import { resolveTokenFromStorage } from '../../session';
import type {
Bilingual,
@@ -526,6 +527,13 @@ export function validateSections(
}
if (empty) continue;
// PhoneInput emits E.164 while typing, so a half-typed "+2519" is a
// non-empty string that still has to be caught here.
if (field.type === 'PHONE' && !isValidPhoneNumber(String(value))) {
errors[`${section.key}.${field.key}`] = 'Enter a valid phone number';
continue;
}
const numeric = Number(value);
if (!Number.isNaN(numeric)) {
if (field.min !== undefined && numeric < field.min) {