MCPcopy Index your code
hub / github.com/cameri/nostream / validateSchema

Function validateSchema

src/utils/validation.ts:3–9  ·  view source on GitHub ↗
(schema: z.ZodTypeAny)

Source from the content-addressed store, hash-verified

1import { z } from 'zod'
2
3export const validateSchema = (schema: z.ZodTypeAny) => (input: unknown) => {
4 const result = schema.safeParse(input)
5 if (!result.success) {
6 return { value: undefined, error: (result as z.SafeParseError<unknown>).error }
7 }
8 return { value: result.data, error: undefined }
9}
10
11export const attemptValidation = (schema: z.ZodTypeAny) => (input: unknown) => schema.parse(input)

Calls

no outgoing calls

Tested by

no test coverage detected