mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-20 02:56:10 +00:00
fix(shared): parse an id param's digits with Number before the integer check
The union of an integer and a digit string fed z.coerce.number() through pipe(), which Zod 4 types with an unknown input and tsc refuses. The digits are now turned into a number with Number and checked by z.number().int().positive(), the same rule as before.
This commit is contained in:
@@ -18,7 +18,8 @@ export type Id = z.infer<typeof idSchema>;
|
||||
*/
|
||||
export const idParamSchema = z
|
||||
.union([z.number().int(), z.string().regex(/^\d+$/)])
|
||||
.pipe(z.coerce.number().int().positive());
|
||||
.transform(Number)
|
||||
.pipe(z.number().int().positive());
|
||||
|
||||
/**
|
||||
* A row id written as text: decimal digits naming a safe integer, kept as the
|
||||
|
||||
Reference in New Issue
Block a user