Rocky_Mountain_Vending/.pnpm-store/v10/files/40/b2b52f080603d251f0cf5133715a77d7c2722f9f90e633804961ea1f318e8b9718136eaeba53e203c88a6b91e715afd1aa966e703c1d6b3ab7000b5e4f4973
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

31 lines
991 B
Text

import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';
import { ArkErrors } from 'arktype';
import { FieldError, FieldErrors } from 'react-hook-form';
import type { Resolver } from './types';
const parseErrorSchema = (e: ArkErrors): Record<string, FieldError> => {
// copy code to type to match FieldError shape
e.forEach((e) => Object.assign(e, { type: e.code }));
// need to cast here because TS doesn't understand we added the type field
return e.byPath as never;
};
export const arktypeResolver: Resolver =
(schema, _schemaOptions, resolverOptions = {}) =>
(values, _, options) => {
const out = schema(values);
if (out instanceof ArkErrors) {
return {
values: {},
errors: toNestErrors(parseErrorSchema(out), options),
};
}
options.shouldUseNativeValidation && validateFieldsNatively({}, options);
return {
errors: {} as FieldErrors,
values: resolverOptions.raw ? values : out,
};
};