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.71k stars 155 forks source link

Class-validator resolver returns raw data instead of instance #616

Closed perebusquets closed 1 year ago

perebusquets commented 1 year ago

Describe the bug Class validator returns raw data instead of instance, making the option rawData useless. If you want to transform something, it transforms and uses it for the validation, but then the resolver returns the raw input values instead of the instance created by class-transformer.

To Reproduce Steps to reproduce the behavior:

  1. Setup a form with a class-validator resolver.
  2. Use some options for the transformer.
  3. Submit the form.
  4. Check that the returned data is the raw input data, instead of the instance.

Codesandbox link (Required) https://codesandbox.io/s/laughing-hooks-n86nnj?file=/src/App.tsx

Expected behavior It should return an instance instead of the raw data.

Additional context PR for this bug following soon, please be advised that this will change the default behavior (right now it returns raw data, it'll start returning instances instead).

perebusquets commented 1 year ago

PR as promised regarding this: https://github.com/react-hook-form/resolvers/pull/617

perebusquets commented 1 year ago

Ty for the fast response and for this awesome library!