From e483eba1a965abbf178347e94e0aa425061e13cb Mon Sep 17 00:00:00 2001 From: Chaim Date: Sat, 11 Apr 2026 16:44:25 +0000 Subject: [PATCH] Allow two case-number formats: NNNN-YY and NNNN-MM-YY MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Narrow the regex to exactly the two hyphen-separated shapes Dafna uses in practice (1033-25, 1000-04-26). Wider shapes like "1033-foo" are rejected too — they didn't exist in any real case and would quietly widen the surface area for routing bugs later. Co-Authored-By: Claude Opus 4.6 (1M context) --- web-ui/src/components/wizard/case-wizard.tsx | 2 +- web-ui/src/lib/schemas/case.ts | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/web-ui/src/components/wizard/case-wizard.tsx b/web-ui/src/components/wizard/case-wizard.tsx index 88700d6..1cbee72 100644 --- a/web-ui/src/components/wizard/case-wizard.tsx +++ b/web-ui/src/components/wizard/case-wizard.tsx @@ -123,7 +123,7 @@ export function CaseWizard() { diff --git a/web-ui/src/lib/schemas/case.ts b/web-ui/src/lib/schemas/case.ts index 39053b1..7427929 100644 --- a/web-ui/src/lib/schemas/case.ts +++ b/web-ui/src/lib/schemas/case.ts @@ -12,12 +12,15 @@ import { z } from "zod"; /* Appeal numbers follow the 1xxx / 8xxx / 9xxx convention from CLAUDE.md. + * Two accepted formats, both hyphen-separated: + * NNNN-YY → "1033-25" (case sequence + 2-digit year) + * NNNN-MM-YY → "1000-04-26" (case sequence + 2-digit month + year) + * * Slashes are deliberately forbidden: FastAPI path routing can't capture - * a `/` inside a case-number segment even when URL-encoded as %2F, so - * any case created with a slash becomes unreachable at - * GET /api/cases/{case_number}/details. Existing prod cases use hyphens - * (e.g. "1033-25", "1130-25") which is the enforced convention here. */ -const caseNumberRe = /^[1-9]\d{3,}(?:-[\w\u0590-\u05FF]+)*$/; + * a `/` inside a {case_number} segment even when URL-encoded as %2F, so + * any case with a slash becomes unreachable at + * GET /api/cases/{case_number}/details. */ +const caseNumberRe = /^[1-9]\d{3}(?:-\d{2}){1,2}$/; const hebrewPartyRe = /[\u0590-\u05FFA-Za-z]/; @@ -41,7 +44,7 @@ export const caseCreateSchema = z.object({ .string() .trim() .min(1, "שדה חובה") - .regex(caseNumberRe, "מספר תיק לא תקין — השתמש במקף, לא בקו נטוי (למשל 1033-25)"), + .regex(caseNumberRe, "פורמט: NNNN-YY או NNNN-MM-YY (למשל 1033-25 או 1000-04-26)"), title: z.string().trim().min(3, "כותרת קצרה מדי").max(200, "כותרת ארוכה מדי"), appellants: z .array(z.string().trim().min(1).refine((v) => hebrewPartyRe.test(v), "שם לא תקין"))