UNPKG

@modular-forms/qwik

Version:

The modular and type-safe form library for Qwik

20 lines (19 loc) 560 B
import { $, implicit$FirstArg } from '@builder.io/qwik'; import { getParsedZodSchema } from '../utils'; /** * See {@link zodField$} */ export function zodFieldQrl(schema) { return $(async (value) => { const result = await getParsedZodSchema(schema, value); return result.success ? '' : result.error.issues[0].message; }); } /** * Creates a validation functions that parses the Zod schema of a field. * * @param schema A Zod schema. * * @returns A validation function. */ export const zodField$ = implicit$FirstArg(zodFieldQrl);