-
Notifications
You must be signed in to change notification settings - Fork 24
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
Unable to make checkbox required #42
Comments
if you want to make a "Terms of Service" kinda check:
and then make a custom field in your form for the "tos"-field :) |
Thank you! |
@LandSprutte Okay, so I am actually running into an issue with this. It looks like when I create a custom input then the data is coming through as just empty strings. Any idea on this? |
@jnoahjohnson try: tos: z.custom((data) => data, {
message: "must accept TOS",
}),
...... // other stuff
<Field name="tos" fieldType="boolean" type="checkbox" ....>
...
</Field> You'll get the object { tos: "on" } 😉 and error message if not "checked" |
Perfect, that worked. Thank you! |
I'm closing this as completed since it seems the issue was resolved. Please feel free to reopen it if needed. |
Like this, you don't need to customise the Field
|
I am trying to make a checkbox required to be true within the zod schema, but the form is still submitting no matter what I have tried so far. There is an example that shows this on the website, but it just sets the default to false. It has a required indicator, but accepts either true or false.
Is there a way to do this currently?
The text was updated successfully, but these errors were encountered: