Use createSafeActionClient without providing a schema #69
-
Hi, I'm wondering is it possible to use createSafeActionClient without passing a schema as an argument? I want to benefit from the user context and role verification but I don't have any properties to pass to my server action |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
The workaround that I found is to pass an empty schema but that bothers me a bit. Would it be possible to make the schema optional? |
Beta Was this translation helpful? Give feedback.
-
It seems to me that, in general, this scheme should be incorporated into the action and be called a validator. export default action(async (data: Data, context: Context): Promise<void> => {
const schema = z.object({
name: z.string()
})
validator.validate(data, schema)
revalidatePath('/admin/oauth/clients')
redirect(`/admin/oauth/clients/${context.clientId}`)
}) |
Beta Was this translation helpful? Give feedback.
We'll see with #48 and Form Actions. For now, as you said, you can pass
z.void()
(assuming you're using Zod).