Our great sponsors
-
youtube-2021-march-nextjs-api-routes-validation-yup
Next.js API Routes validation shared with front-end using yup
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
-
resolvers
📋 Validation resolvers: Yup, Zod, AJV, Joi, Superstruct, Vest, class-validator, io-ts, typanion, Ajv, TypeBox, Valibot and nope.
I see there is next-joi api example but which form library integrates well with Joi schemas?
I know Yup schemas are native for Formik but then for api best example that I found is this but this is not some high level integration, just validate() function is called in middleware before api handler.
It's a bit of a PITA to do validation in API routes. If you use TypeScript - check out ZOD: https://github.com/colinhacks/zod, if no - joi is way to go.
For the front-end, I like react-hook-form, and it supports both zod, joi, yup and more via official package: https://github.com/react-hook-form/resolvers