From 9ae3d5e9c7a60e8e7b8aa6f4b8518329b127fdac Mon Sep 17 00:00:00 2001 From: Temuulen Ankhbayar Date: Sat, 7 Mar 2026 11:16:58 +0900 Subject: [PATCH] fix: enforce 32-digit numeric EID validation with inline user feedback EID input now strips non-numeric characters, shows a digit counter warning while typing, and enforces exactly 32 digits via Zod schemas across domain, order configurations, and order selections layers. Also installs missing input-otp dependency. Co-Authored-By: Claude Opus 4.6 --- .../components/sim/SimTypeSelector.tsx | 20 ++++++++++++++----- packages/domain/orders/schema.ts | 10 ++++++++-- packages/domain/sim/schema.ts | 12 ++++++----- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/apps/portal/src/features/services/components/sim/SimTypeSelector.tsx b/apps/portal/src/features/services/components/sim/SimTypeSelector.tsx index 4a9736f7..bf20077f 100644 --- a/apps/portal/src/features/services/components/sim/SimTypeSelector.tsx +++ b/apps/portal/src/features/services/components/sim/SimTypeSelector.tsx @@ -138,6 +138,12 @@ function PhysicalSimOption({ ); } +function getEidWarning(eid: string): string | undefined { + if (!eid) return undefined; + if (eid.length < 32) return `EID must be 32 digits (${eid.length}/32)`; + return undefined; +} + function EidInput({ simType, eid, @@ -150,6 +156,8 @@ function EidInput({ errors: Record; }) { const [showEidInfo, setShowEidInfo] = useState(false); + const warning = getEidWarning(eid); + const hasError = Boolean(errors["eid"]); return (
onEidChange(e.target.value)} - className={`w-full px-4 py-3 bg-card border rounded-lg text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-primary transition-colors ${ - errors["eid"] ? "border-destructive" : "border-border" + onChange={e => onEidChange(e.target.value.replace(/\D/g, "").slice(0, 32))} + className={`w-full px-4 py-3 bg-card border rounded-lg text-foreground font-mono tracking-wider placeholder:text-muted-foreground placeholder:font-sans placeholder:tracking-normal focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-primary transition-colors ${ + hasError ? "border-destructive" : warning ? "border-warning" : "border-border" }`} - placeholder="32-digit EID number" + placeholder="32-digit EID number (numbers only)" maxLength={32} /> - {errors["eid"] &&

{errors["eid"]}

} + {hasError &&

{errors["eid"]}

} + {!hasError && warning &&

{warning}

}