import { z } from 'zod'
import { makeDomainFunction } from 'domain-functions'
import { formAction } from '~/form-action'
import { Form } from '~/form'
const schema = z.object({
firstName: z.string().min(1),
email: z.string().min(1).email(),
howYouFoundOutAboutUs: z.enum(['fromAFriend', 'google']),
})
const mutation = makeDomainFunction(schema)(async (values) => values)
export const action: ActionFunction = async ({ request }) =>
formAction({
request,
schema,
mutation,
successPath: '/success',
})
export default () => <Form schema={schema} />
This tiny code creates the form below ๐๐ฝ
E2E type-safe, with client + server validations, a11y, pending UI, and focus management