UNPKG

@swastikbhattacharyya/next-actions

Version:

A type-safe utility for defining server actions and backend data access layers.

25 lines (22 loc) 930 B
import z from 'zod'; import { $ZodType, $ZodIssue } from 'zod/v4/core'; import { ValidationResultWithoutContext } from '../types.js'; /** * A validator that checks input against a given Zod schema. * * If parsing fails, it returns a validation result containing the list of * Zod issues under the error code `"zodValidator_invalidParams"`. * * @template Schema - The Zod schema used to validate the input. * @param schema - The Zod schema instance. * @param params - The parameters to validate. * @returns A promise resolving to a ValidationResult. If parsing fails then * the result contains the error code `"zodValidator_invalidParams` along with * the list of Zod issues. */ declare function zodValidator<Schema extends $ZodType>(schema: Schema, params: z.infer<Schema>): Promise<ValidationResultWithoutContext<{ zodValidator_invalidParams: { issues: $ZodIssue[]; }; }>>; export { zodValidator };