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

[Bug]: zod-form-data sets fields as optional, while the docs state otherwise, in the type that is #323

Closed
1 of 4 tasks
dietergeerts opened this issue Sep 12, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@dietergeerts
Copy link

Which packages are impacted?

  • remix-validated-form
  • @remix-validated-form/with-zod
  • @remix-validated-form/with-yup
  • zod-form-data

What version of these packages are you using?

  • zod-form-data: 2.0.1

Please provide a link to a minimal reproduction of the issue.

Sorry, private repo

Steps to Reproduce the Bug or Issue

The following:

import { zfd } from "zod-form-data";

const formSchema = zfd.formData({
  region_id: zfd.numeric(),
  header: zfd.text(),
});

function onSubmit({ target }: SubmitEvent) {
  updateSettings(
    formSchema.parse(new FormData(target as HTMLFormElement))
  );
}

Gives an error on the function, stating that the properties are required by the function, but are optional from the parse result, while the docs state that by default all things are required, so the type should also reflect this.

Expected behavior

The type reflecting if a property is required or optional correctly according to the schema.

Screenshots or Videos

No response

Platform

  • OS: [Windows 10]

Additional context

No response

@dietergeerts dietergeerts added the bug Something isn't working label Sep 12, 2023
@jvnlwn
Copy link

jvnlwn commented Sep 20, 2023

Possibly your tsconfig settings need adjusting.

@dietergeerts
Copy link
Author

Possibly your tsconfig settings need adjusting.

Thx! That did the trick. Our project is just starting to use TS, and I wasn't aware yet of the full configuration for it :)

@airjp73
Copy link
Owner

airjp73 commented Sep 22, 2023

Sounds like this is resolved. Is it okay to close the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants