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

feat: Support Server Actions #636

Closed kotarella1110 closed 9 months ago

kotarella1110 commented 10 months ago

Related Issue

https://github.com/react-hook-form/react-hook-form/issues/10391

Core PR

https://github.com/react-hook-form/resolvers/pull/636

Summary

This PR is an experimental implementation for supporting Server Actions in React Hook Form. Its purpose is to explore the best way to support Server Actions within React Hook Form, and it's important to note that the changes proposed in this PR may not be adopted as is.

Additionally, this PR makes minimal changes, and there are various other considerations that need to be addressed.

Changes Made

When importing resolvers in a react-server context, the following error occurs:

TypeError: createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component

To resolve this error, we have made changes to import only logic and utilities that have been conditionally exported. Currently, I have changed only to zodResolver.

github-actions[bot] commented 10 months ago

Size Change: +10 B (0%)

Total Size: 25.4 kB

Filename Size Change
dist/resolvers.js 471 B +4 B (+1%)
dist/resolvers.module.js 485 B +3 B (+1%)
dist/resolvers.umd.js 559 B -3 B (-1%)
zod/dist/zod.js 583 B +3 B (+1%)
zod/dist/zod.module.js 605 B +5 B (+1%)
zod/dist/zod.umd.js 685 B -2 B (0%)
ℹ️ View Unchanged | Filename | Size | | :--- | :---: | | `ajv/dist/ajv.js` | 638 B | | `ajv/dist/ajv.module.js` | 594 B | | `ajv/dist/ajv.umd.js` | 750 B | | `arktype/dist/arktype.js` | 328 B | | `arktype/dist/arktype.module.js` | 343 B | | `arktype/dist/arktype.umd.js` | 423 B | | `class-validator/dist/class-validator.js` | 537 B | | `class-validator/dist/class-validator.module.js` | 561 B | | `class-validator/dist/class-validator.umd.js` | 640 B | | `computed-types/dist/computed-types.js` | 387 B | | `computed-types/dist/computed-types.module.js` | 401 B | | `computed-types/dist/computed-types.umd.js` | 477 B | | `io-ts/dist/io-ts.js` | 1.28 kB | | `io-ts/dist/io-ts.module.js` | 1.18 kB | | `io-ts/dist/io-ts.umd.js` | 1.41 kB | | `joi/dist/joi.js` | 591 B | | `joi/dist/joi.module.js` | 609 B | | `joi/dist/joi.umd.js` | 696 B | | `nope/dist/nope.js` | 345 B | | `nope/dist/nope.module.js` | 365 B | | `nope/dist/nope.umd.js` | 434 B | | `superstruct/dist/superstruct.js` | 324 B | | `superstruct/dist/superstruct.module.js` | 342 B | | `superstruct/dist/superstruct.umd.js` | 424 B | | `typanion/dist/typanion.js` | 330 B | | `typanion/dist/typanion.module.js` | 344 B | | `typanion/dist/typanion.umd.js` | 424 B | | `typebox/dist/typebox.js` | 464 B | | `typebox/dist/typebox.module.js` | 481 B | | `typebox/dist/typebox.umd.js` | 579 B | | `valibot/dist/valibot.js` | 577 B | | `valibot/dist/valibot.module.js` | 594 B | | `valibot/dist/valibot.umd.js` | 684 B | | `vest/dist/vest.js` | 479 B | | `vest/dist/vest.module.js` | 443 B | | `vest/dist/vest.umd.js` | 569 B | | `yup/dist/yup.js` | 625 B | | `yup/dist/yup.module.js` | 639 B | | `yup/dist/yup.umd.js` | 728 B |

compressed-size-action