From the course: Next.js Ecommerce: Build a Shopping Platform from Scratch

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Update profile action

Update profile action

So we want to create our profile page. It's going to be a form with the e-mail and the name. We're going to be able to update the name, but not the e-mail, just because that's the login. Now, in this video, I want to create the Zod schema, which is really simple, and that's just for the validation. And then we're going to create the action to update the profile. And in the next video, we'll work on the actual page and the UI. So let's jump into the validators. So Prisma, not Prisma, Lib, and then validators.ts. And we're going to create the Zod schema. And it's just two fields. It's just name and e-mail, so this will be really simple. Let's say schema for updating the user profile. So we'll do export, and we're going to call this update. We'll call it update profile schema. And we want to set that to z.object. And then we're going to pass in our two fields. One is going to be name. And it's going to be a string. And I want to do a min, minimum characters of three. And then for the…

Contents