Allow two case-number formats: NNNN-YY and NNNN-MM-YY
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) <noreply@anthropic.com>
This commit is contained in:
@@ -123,7 +123,7 @@ export function CaseWizard() {
|
|||||||
</Label>
|
</Label>
|
||||||
<Input
|
<Input
|
||||||
id="case_number"
|
id="case_number"
|
||||||
placeholder="1234 או 8001/2026"
|
placeholder="1033-25 או 1000-04-26"
|
||||||
{...form.register("case_number")}
|
{...form.register("case_number")}
|
||||||
className="mt-1 tabular-nums"
|
className="mt-1 tabular-nums"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -12,12 +12,15 @@
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
/* Appeal numbers follow the 1xxx / 8xxx / 9xxx convention from CLAUDE.md.
|
/* 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
|
* Slashes are deliberately forbidden: FastAPI path routing can't capture
|
||||||
* a `/` inside a case-number segment even when URL-encoded as %2F, so
|
* a `/` inside a {case_number} segment even when URL-encoded as %2F, so
|
||||||
* any case created with a slash becomes unreachable at
|
* any case with a slash becomes unreachable at
|
||||||
* GET /api/cases/{case_number}/details. Existing prod cases use hyphens
|
* GET /api/cases/{case_number}/details. */
|
||||||
* (e.g. "1033-25", "1130-25") which is the enforced convention here. */
|
const caseNumberRe = /^[1-9]\d{3}(?:-\d{2}){1,2}$/;
|
||||||
const caseNumberRe = /^[1-9]\d{3,}(?:-[\w\u0590-\u05FF]+)*$/;
|
|
||||||
|
|
||||||
const hebrewPartyRe = /[\u0590-\u05FFA-Za-z]/;
|
const hebrewPartyRe = /[\u0590-\u05FFA-Za-z]/;
|
||||||
|
|
||||||
@@ -41,7 +44,7 @@ export const caseCreateSchema = z.object({
|
|||||||
.string()
|
.string()
|
||||||
.trim()
|
.trim()
|
||||||
.min(1, "שדה חובה")
|
.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, "כותרת ארוכה מדי"),
|
title: z.string().trim().min(3, "כותרת קצרה מדי").max(200, "כותרת ארוכה מדי"),
|
||||||
appellants: z
|
appellants: z
|
||||||
.array(z.string().trim().min(1).refine((v) => hebrewPartyRe.test(v), "שם לא תקין"))
|
.array(z.string().trim().min(1).refine((v) => hebrewPartyRe.test(v), "שם לא תקין"))
|
||||||
|
|||||||
Reference in New Issue
Block a user