UNPKG

@slippy-lint/slippy

Version:

A simple but powerful linter for Solidity

22 lines 693 B
import * as z from "zod"; export const conditionalUnionType = (cases, noMatchMessage) => z.any().superRefine((data, ctx) => { const matchingCase = cases.find(([predicate]) => predicate(data)); if (matchingCase === undefined) { ctx.addIssue({ code: "custom", message: noMatchMessage, }); return; } const zodeType = matchingCase[1]; const parsedData = zodeType.safeParse(data); if (parsedData.error !== undefined) { for (const issue of parsedData.error.issues) { ctx.addIssue({ ...issue, code: "custom", }); } } }); //# sourceMappingURL=zod.js.map