Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onServerValidate doesn't work with standard schema objects #1128

Open
icopp opened this issue Jan 24, 2025 · 0 comments
Open

onServerValidate doesn't work with standard schema objects #1128

icopp opened this issue Jan 24, 2025 · 0 comments

Comments

@icopp
Copy link

icopp commented Jan 24, 2025

Describe the bug

All of the other validators work with StandardSchemaV1, but onServerValidate doesn't.

Your minimal, reproducible example

n/a

Steps to reproduce

// shared-code.ts

import { formOptions } from "@tanstack/react-form/nextjs";
import { object, picklist } from "valibot";

export const formSchema = object({ 
  animal: picklist(['cats', 'dogs'])
})

export const formOpts = formOptions({
  validators: {
    onSubmit: formSchema,
  },
});
// server-actions.ts

"use server";

import { createServerValidate } from "@tanstack/react-form/nextjs";
import { formSchema, formOpts } from "./shared-code.ts";

const serverValidate = createServerValidate({
   ...formOpts,
   onServerValidate: formSchema // incompatible object type
})

Expected behavior

It should be possible to use the same schema for both other validators and onServerValidate.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

n/a, applies to all platforms

TanStack Form adapter

None

TanStack Form version

0.41.3

TypeScript version

5.7.3

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant