Giter VIP home page Giter VIP logo

Comments (9)

jorisre avatar jorisre commented on May 13, 2024 8

Hi @Smona 👋🏻

FIY Yup sync validation added in the v2.0.0-beta.5
You can try it by installing yarn add @hookform/[email protected]

from resolvers.

Smona avatar Smona commented on May 13, 2024 2

@jorisre hey, awesome! Thanks for taking this on

from resolvers.

bluebill1049 avatar bluebill1049 commented on May 13, 2024 1

@GollyJer v6 will not return defaultValue from watch, unless supplied as default values

watch(undefined, defualtValues)

we are fixing this behaviour for V7, so defaultValue will be returned before render.

from resolvers.

bluebill1049 avatar bluebill1049 commented on May 13, 2024

resolver: async (data) => schema.validateSync(data)

have you tried to build your own?

from resolvers.

Smona avatar Smona commented on May 13, 2024

No, not yet. I could, but then I would have to copy-paste the source code for the error parser and other imports of the resolver. Which kind of defeats the purpose of the repo 😅

I'd be happy to submit a PR here if you approve of the idea!

from resolvers.

Smona avatar Smona commented on May 13, 2024

I suppose I'm assuming that useForm would support a synchronous validation resolver. If that's not the case, I can see why this would be harder to implement.

from resolvers.

GollyJer avatar GollyJer commented on May 13, 2024

HI @jorisre 👋

Stumbled on this today looking for a synchronous solution.
I have

"@hookform/resolvers": "2.0.0-beta.5",
"react-hook-form": "^6.14.2",

And the following code.

const { control, errors, watch, formState } = useForm<FormInputs>({
    mode: 'onChange',
    reValidateMode: 'onChange',
    defaultValues,
    resolver: yupResolver(
      Yup.object().shape({
        syringeUnits: Yup.number().required().moreThan(0),
        syringeTickMarks: Yup.number().required().moreThan(0),
        powderMilligrams: Yup.number().required().moreThan(0),
        waterMilliliters: Yup.number().required().moreThan(0),
        desiredDoseAmount: Yup.number().required().moreThan(0),
      }),
      undefined,
      { mode: 'sync' }
    ),
  });

  const formValues = watch();
  console.log(formValues);

I'm still seeing formValues print the old and new value when typing in a field.
Am I doing something wrong?

Thanks for the work on this! It's going to be super helpful.

from resolvers.

GollyJer avatar GollyJer commented on May 13, 2024

@bluebill1049 Good to know. Thanks!

from resolvers.

jorisre avatar jorisre commented on May 13, 2024

Closing, V2 released 🎉

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.