Coder Social home page Coder Social logo

Comments (7)

LandSprutte avatar LandSprutte commented on May 21, 2024

if you want to make a "Terms of Service" kinda check:

tos: z.custom((data) => data === true, { message: "You have to accept the terms of service", }),

and then make a custom field in your form for the "tos"-field :)

from remix-forms.

jnoahjohnson avatar jnoahjohnson commented on May 21, 2024

Thank you!

from remix-forms.

jnoahjohnson avatar jnoahjohnson commented on May 21, 2024

@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?

Screen Shot 2022-06-29 at 8 00 08 PM

Screen Shot 2022-06-29 at 8 00 17 PM

from remix-forms.

LandSprutte avatar LandSprutte commented on May 21, 2024

@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"

from remix-forms.

jnoahjohnson avatar jnoahjohnson commented on May 21, 2024

Perfect, that worked. Thank you!

from remix-forms.

felipefreitag avatar felipefreitag commented on May 21, 2024

I'm closing this as completed since it seems the issue was resolved. Please feel free to reopen it if needed.

from remix-forms.

mauscoelho avatar mauscoelho commented on May 21, 2024

Like this, you don't need to customise the Field

privacy: z.boolean().refine(value => value === true, { message: 'You must agree to the privacy statement' })

from remix-forms.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.