You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 16, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Oct 16, 2026. It is now read-only.
refactor: unify targets validation into Zod schema (single source of truth) #909
Adding use_target required changes in 3 places: TargetDefinition interface, Zod schema, and the manual validator. This is brittle — each new field risks the two systems diverging.
Proposal
Make the Zod schema the single source of truth. Move validator logic into Zod .refine() and .superRefine():
constTargetSchema=z.object({name: z.string().min(1),provider: z.string().optional(),use_target: z.string().optional(),grader_target: z.string().optional(),// ...}).superRefine((data,ctx)=>{// Provider required unless use_target is setif(!data.use_target&&!data.provider){ctx.addIssue({code: z.ZodIssueCode.custom,message: "Either 'provider' or 'use_target' is required",path: ['provider'],});}// Env var syntax validationif(data.provider&&/^\$\{\{/.test(data.provider)){// validate env var format}});
Benefits
One schema defines structure, types, AND validation rules
TargetDefinition type is inferred from schema (z.infer<typeof TargetSchema>)
Adding a new field = one change in one place
Validation errors include Zod's structured path information
Prior art
Vitest: single Zod schema for config validation + typing
tRPC: Zod schemas as single source of truth for input validation
Astro: Zod content collections schema (validates + types in one pass)
Activity
fix(core): allow use_target in targets-file.ts parser
fix(core): allow use_target in targets-file.ts parser
feat(evals): set default targets so all evals work out of the box (#898)