Joi validation works in code sandbox but not when running locally

Describe the bug

  • Joi validation works in code sandbox but not when running locally
  • And no data is displayed when I click on the submit button
  • In the code sandbox it works like I expect it

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://codesandbox.io/s/react-hook-form-joiresolver-v6-yejqe?file=/src/index.js
  2. Download the files
  3. Run “npm i” in the folder
  4. Start with “start” script

Codesandbox link (Required)
https://codesandbox.io/s/react-hook-form-joiresolver-v6-yejqe?file=/src/index.js

Expected behavior
Validation like in the code sandbox, username display in the alert

Screenshots
https://user-images.githubusercontent.com/41862965/109089198-2131e700-7711-11eb-8b2d-67eac4903038.mov

Desktop (please complete the following information):

  • OS: macOS Big Sur
  • Browser:Chorme
  • Version: Chrome 84.0.4147.135 (Official Build) (64-bit)

2 thoughts on “Joi validation works in code sandbox but not when running locally

  1. Hi @juliushuck 👋🏻

    Firstly, you can use joi instead of @hapi/joi

    After investigation, the problem schema seems not be in React Hook Form / @hookform/resolvers.

    You can try to validate your schema:

    try {
        await schema.validateAsync(values);
    } catch(e) {
        // Got an error, but not the expected error, I think it's a Joi issue
    }