Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | 10x | import type { FormErrors } from '@mantine/form';
import type { ZodType } from 'zod';
/**
* Custom zodResolver compatible with @mantine/form v9.
* Replaces mantine-form-zod-resolver which only supports Mantine v7.
*/
export function zodResolver(schema: ZodType) {
return (values: unknown): FormErrors => {
const result = schema.safeParse(values);
if (result.success) return {};
return Object.fromEntries(
result.error.issues.map((issue) => [issue.path.join('.'), issue.message]),
);
};
}
|