import { z } from 'zod'
import { applySchema } from 'composable-functions'
import { formAction, SchemaForm } from 'remix-forms'
const schema = z.object({
firstName: z.string().min(1),
email: z.string().min(1).email(),
howDidYouFindUs: z.enum(['aFriend', 'google']),
})
const mutation = applySchema(schema)(async (values) => values)
export const action = async ({ request }: Route.ActionArgs) =>
formAction({
request,
schema,
mutation,
successPath: '/success',
})
export default () => <SchemaForm schema={schema} />
This tiny code creates the form below ๐๐ฝ
E2E type-safe, with client + server validations, a11y, pending UI, and focus management