(jsonObject: object)
| 21 | return validator; |
| 22 | |
| 23 | function validate(jsonObject: object) { |
| 24 | const result = schema[typeName].safeParse(jsonObject); |
| 25 | if (!result.success) { |
| 26 | return error(result.error.issues.map(({ path, message }) => `${path.map(key => `[${JSON.stringify(key)}]`).join("")}: ${message}`).join("\n")); |
| 27 | } |
| 28 | return success(result.data as z.infer<T[K]> & object); |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | // ZodTypeKind is the union of all type-discriminant strings defined by Zod v4. |