@alextheman/utility - v5.10.1
    Preparing search index...

    Function parseZodSchemaAsync

    • An alternative function to zodSchema.parseAsync() that can be used to strictly parse asynchronous Zod schemas.

      Type Parameters

      • SchemaType extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>

        The Zod schema type.

      • ErrorType extends Error = DataError<Record<PropertyKey, unknown>>

        The type of error to throw on invalid data.

      Parameters

      • schema: SchemaType

        The Zod schema to use in parsing.

      • input: unknown

        The data to parse.

      • OptionalonError: ErrorType | ((zodError: ZodError) => void | ErrorType)

        A custom error to throw on invalid data (defaults to DataError). May either be the error itself, or a function that returns the error or nothing. If nothing is returned, the default error is thrown instead.

      Returns Promise<output<SchemaType>>

      The parsed data from the Zod schema.

      If the given data cannot be parsed according to the schema.