react-hook-form / resolvers

📋 Validation resolvers: Yup, Zod, Superstruct, Joi, Vest, Class Validator, io-ts, Nope, computed-types, typanion, Ajv, TypeBox, ArkType, Valibot, effect-ts and VineJS
https://react-hook-form.com/
MIT License
1.67k stars 151 forks source link

errors object creating circular structure with yup resolver #660

Open brianbattenfeld opened 5 months ago

brianbattenfeld commented 5 months ago

Describe the bug When trying to stringify my errors object, I'm receiving a TypeError Converting circular structure to JSON

To Reproduce Steps to reproduce the behavior:

  1. Go to the codesandbox https://6x7zpv.csb.app/ (which is a fork of the example found here, with only the JSON.stringify() added)
  2. Fill out no inputs and submit to force an error to be created
  3. See TypeError surfaced in browser

Codesandbox link (Required)

Expected behavior I'd expect to see the errors object displayed as a string above the form

Screenshots Screenshot 2024-01-24 at 5 36 23 PM Screenshot 2024-01-24 at 5 37 04 PM

Desktop (please complete the following information):

Additional context Stringifying errors (as well as the rest of the formState) is often useful for me and my team to be able to quickly reference within the UI in dev environments to troubleshoot.