diff --git a/lib/components/trace.ts b/lib/components/trace.ts index 22767820..a8440104 100644 --- a/lib/components/trace.ts +++ b/lib/components/trace.ts @@ -59,6 +59,12 @@ const baseTraceProps = z.object({ schStroke: z.string().optional(), highlightColor: z.string().optional(), maxLength: distance.optional(), + maxViaCount: z + .number() + .int() + .nonnegative() + .optional() + .describe("Maximum number of vias allowed in the PCB trace route"), connectsTo: z.string().or(z.array(z.string())).optional(), }) diff --git a/tests/trace.test.ts b/tests/trace.test.ts index cb24844f..5fb2b9a7 100644 --- a/tests/trace.test.ts +++ b/tests/trace.test.ts @@ -89,6 +89,20 @@ test("supports pcbStraightLine flag", () => { expect(parsed.pcbStraightLine).toBe(true) }) +test("supports limiting the maximum number of PCB vias", () => { + const raw: TraceProps = { + from: "A", + to: "B", + maxViaCount: 0, + } + + const parsed = traceProps.parse(raw) + + expect(parsed.maxViaCount).toBe(0) + expect(() => traceProps.parse({ ...raw, maxViaCount: -1 })).toThrow() + expect(() => traceProps.parse({ ...raw, maxViaCount: 1.5 })).toThrow() +}) + test("accepts start/end aliases for trace endpoints", () => { const raw: TraceProps = { start: "A",