Modernise zod idioms to v4
Replace the deprecated v3 string-method forms with the top-level
validator helpers zod 4 prefers:
- z.string().url() → z.url() (3 sites)
- z.string().uuid() → z.uuid() (5 sites)
- z.string().datetime() → z.iso.datetime() (9 sites)
Also swap the ZodIssueCode.custom compat-shim reference in
demo-bot.server.ts's superRefine for the bare string literal "custom",
which is v4's idiomatic form. No runtime change.
All 147 tests still pass.
The `parsed.error.issues.map(i => ({field, message}))` pattern in the
five journal API route handlers stays as-is — the fields we read are
unchanged in v4, and zod's new error helpers (z.treeifyError,
z.prettifyError) produce different shapes that would change our
public API error contract.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
0eea6f2047
commit
079c3de90c
6 changed files with 20 additions and 20 deletions
|
|
@ -2,7 +2,7 @@ import { z } from "zod";
|
|||
|
||||
/** Route summary for list views */
|
||||
export const RouteSummarySchema = z.object({
|
||||
id: z.string().uuid(),
|
||||
id: z.uuid(),
|
||||
name: z.string(),
|
||||
description: z.string(),
|
||||
distance: z.number().nullable(),
|
||||
|
|
@ -11,15 +11,15 @@ export const RouteSummarySchema = z.object({
|
|||
routingProfile: z.string().nullable(),
|
||||
dayBreaks: z.array(z.number()),
|
||||
geojson: z.string().nullable(),
|
||||
createdAt: z.string().datetime(),
|
||||
updatedAt: z.string().datetime(),
|
||||
createdAt: z.iso.datetime(),
|
||||
updatedAt: z.iso.datetime(),
|
||||
});
|
||||
|
||||
/** Route version info */
|
||||
export const RouteVersionSchema = z.object({
|
||||
version: z.number(),
|
||||
changeDescription: z.string().nullable(),
|
||||
createdAt: z.string().datetime(),
|
||||
createdAt: z.iso.datetime(),
|
||||
});
|
||||
|
||||
/** Full route detail */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue