Giter VIP home page Giter VIP logo

Comments (3)

chanthinh avatar chanthinh commented on May 23, 2024

Hi @JolianGof,
You are missing firstName and age in your schema, add these to your schema and try again

export const formSchema = object({
  lastName: string([
    minLength(1, "This field is required."),
    maxLength(5, "Please enter within 2 characters."),
  ]),
firstName: string(),
age: string()
});

from resolvers.

JolianGof avatar JolianGof commented on May 23, 2024

Hi,

Thank you for the response. I understand that the valibotResolver requires all fields in the form to be defined in the validation schema. However, in my case, I have a large form and I only want to validate some of the fields.

For instance, if I have a form with fields firstName, lastName, age, and many others, and I only want to validate firstName and age, how would I go about doing that?

Should I include all fields in the schema and provide simple validation rules like string() or number() for the fields I don't want to validate? Or is there a better way to handle this scenario?

Thank you for your guidance.

from resolvers.

chanthinh avatar chanthinh commented on May 23, 2024

@JolianGof,
I understand what you want, so you can try to use yupResolver
Check this one: https://codesandbox.io/p/sandbox/react-hook-form-yup-resolver-forked-4k44jg?file=%2Fsrc%2FcolorScheme.js%3A11%2C4

from resolvers.

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.