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

Extended server action using a custom helper causes unexpected error during validation triggered by Conform #795

Open
ChristianIvicevic opened this issue Sep 29, 2024 · 0 comments

Comments

@ChristianIvicevic
Copy link

ChristianIvicevic commented Sep 29, 2024

Describe the bug and the expected behavior

In an attempt to reduce the need for separate files in Next.js projects I was looking forward to write a helper defining a server action that also exposes the schema so that its definition can be inlined/colocated in the action definition. This doesn't work unfortunately as Conform's validation seemingly attempts to access the custom property or does something unexpected with the passed schema causing errors.

TypeError: undefined is not an object (evaluating 'type._def')

Conform version

v1.2.2

Steps to Reproduce the Bug or Issue

  1. Clone my fork over at https://github.com/ChristianIvicevic/conform/
  2. Run the Next.js example and go to the login form
  3. Enter some invalid email and move to the next field and notice how the error appears

What browsers are you seeing the problem on?

Chrome, Safari

Screenshots or Videos

No response

Additional context

You can check my latest commit adding my intended helper and how I'm referencing the schema: ChristianIvicevic@b1242ea

It's noticeable that it's triggered by Conform as the error gets delayed when you change the validation strategy to onSubmit. My gut feeling is that Conform attempts to manipulate or access the passed schema in a way that's not compatible with it being part of the action.

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