@conform-to/zod
Version:
Conform helpers for integrating with Zod
33 lines • 1.36 kB
TypeScript
import type { ZodSafeParseResult, core } from 'zod/v4';
import type { FormError } from '@conform-to/dom/future';
/**
* Transforms Zod validation results into Conform's error format.
*
* **Example:**
* ```ts
* const result = schema.safeParse(formData);
* const error = formatResult(result);
* ```
*/
export declare function formatResult<Output>(result: ZodSafeParseResult<Output>): FormError<string[]> | null;
export declare function formatResult<Output, ErrorShape = string[]>(result: ZodSafeParseResult<Output>, options: {
/** Whether to include the parsed value in the returned object */
includeValue: true;
/** Custom function to format validation issues for each field */
formatIssues: (issue: core.$ZodIssue[], name: string) => ErrorShape;
}): {
error: FormError<ErrorShape> | null;
value: Output | undefined;
};
export declare function formatResult<Output>(result: ZodSafeParseResult<Output>, options: {
includeValue: true;
formatIssues?: undefined;
}): {
error: FormError<string[]> | null;
value: Output | undefined;
};
export declare function formatResult<Output, ErrorShape = string[]>(result: ZodSafeParseResult<Output>, options: {
includeValue?: false;
formatIssues: (issue: core.$ZodIssue[], name: string) => ErrorShape;
}): FormError<ErrorShape> | null;
//# sourceMappingURL=format.d.ts.map