Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 72x 648x 648x 49x 49x 17x | import { z, SuperRefinement } from "zod"; export const validId = (idRegex: RegExp, message: string): SuperRefinement<string> => { const correctFormatSchema = z.string().regex(idRegex, { message, }); return (val, ctx) => { const result = correctFormatSchema.safeParse(val); if (!result.success) { ctx.addIssue({ message: result.error.issues.at(0)?.message, code: z.ZodIssueCode.custom, fatal: true, }); } }; }; |