Validate Data With Zod in Server Actions Next.js (Client-Side + Server-Side)

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ก.ย. 2024
  • 👉 NEW React & Next.js Course: bytegrad.com/c...
    Hi, I'm Wesley. I'm a brand ambassador for Kinde (paid sponsorship).
    👉 Add authentication to your app FAST: bit.ly/3QOe1Bh
    👉 NEW React & Next.js Course: bytegrad.com/c...
    👉 Professional JavaScript Course: bytegrad.com/c...
    👉 Professional CSS Course: bytegrad.com/c...
    👉 Discord: all my courses have a private Discord where I actively participate
    🔔 Email newsletter (BIG update soon): email.bytegrad...
    ⏱️ Timestamps:
    0:00 Solution
    #webdevelopment #programming #coding

ความคิดเห็น • 26

  • @meka4996
    @meka4996 11 หลายเดือนก่อน +8

    This is so amazing!!! This is much easier than React Hook Form + Zod! Thanks

    • @mukulsinghbisht2434
      @mukulsinghbisht2434 5 หลายเดือนก่อน

      React hook form has its own advantages

  • @snivels
    @snivels ปีที่แล้ว +3

    Exceptionally well explained. Great video!

  • @hamzamellahi120
    @hamzamellahi120 11 หลายเดือนก่อน +2

    love your videos, please make more!

  • @wingy3181
    @wingy3181 11 หลายเดือนก่อน +1

    Question: do you think the revalidation of the mutated data should be decoupled from the server action? that is, i notice that revalidatePath("/todos") is inside the server action....which means it couples the path to the server action....

  • @jeromealtariba7339
    @jeromealtariba7339 8 หลายเดือนก่อน +1

    Hi, this is a nice video, however, when using actions (on not the onSubmit prop of the form), the client side validation is not triggerring at all. Only the server side validation is displayed.

  • @psyferinc.3573
    @psyferinc.3573 11 หลายเดือนก่อน +1

    thanks
    looking for a zod tutorial now

  • @codiwebcat
    @codiwebcat 9 หลายเดือนก่อน +1

    Fantastic video and all your content!

  • @aymenbachiri-yh2hd
    @aymenbachiri-yh2hd 2 หลายเดือนก่อน

    very clean explanation, thank you somuch

  • @ajlmusic
    @ajlmusic 8 หลายเดือนก่อน +1

    Excellent!

  • @MuhamadAzizPrasetyo
    @MuhamadAzizPrasetyo 2 หลายเดือนก่อน +1

    Thank you ☺☺

  • @writterpanditsid5048
    @writterpanditsid5048 7 หลายเดือนก่อน +1

    Thanks

  • @lrnngman2942
    @lrnngman2942 11 หลายเดือนก่อน

    Can I use React hook form with Zod?
    or should using only 1way?

  • @BuryneJoel
    @BuryneJoel ปีที่แล้ว +1

    Thank you sir

  • @eSeMGie
    @eSeMGie 4 หลายเดือนก่อน

    Great wideo! That's exactly what I was looking for. I have a question though. Why do we need validation on the client and server side? It seems to be redundant. Is any possible way to pass validation one the client side and fail validation one the server side? We actually passed already validated data to the server.

    • @WebDevNiko
      @WebDevNiko 4 หลายเดือนก่อน +2

      client side validation is used to give normal user feedback if validation fails but you want also server side validation before pushing the data to database etc since client side isnt to be trusted as its easyer to modify and pass the validation if you would want to do that

    • @eSeMGie
      @eSeMGie 4 หลายเดือนก่อน

      @@WebDevNiko Big thanks for clarification!

    • @eSeMGie
      @eSeMGie 4 หลายเดือนก่อน

      @@WebDevNiko I wonder, why we can't just make a validation on the server side, and then if validation failed return all error messages to client and give the user feedback?

    • @WebDevNiko
      @WebDevNiko 4 หลายเดือนก่อน +1

      @@eSeMGie you could do that but having extra validation on client side prevents sending unnecessary requests to server side, eg every time user forget to type last name you wont send request to server. Basically its just more efficent to have validation both on client and server side especially with zod since u can reuse the schema easyly so its effortless

  • @swdotdev
    @swdotdev 6 หลายเดือนก่อน

    Well the only problem with zod is that it makes large scale apps significantly slower. Other than that, yea it is great for sure.

  • @GabrielLogan17
    @GabrielLogan17 3 หลายเดือนก่อน

    Try my library too, multiform-validator

  • @easy_frontend
    @easy_frontend 2 วันที่ผ่านมา

    if you could please would you share the code

  • @janyumi1995
    @janyumi1995 2 หลายเดือนก่อน +1

    cool

  • @Hicham-z7t
    @Hicham-z7t 11 หลายเดือนก่อน +1

    you got great videos, but it is so hard to follow you as you speak too fast. thx

    • @celsopires1999
      @celsopires1999 11 หลายเดือนก่อน +1

      you can reduce the video speed if it too fast for you

    • @sskular
      @sskular 10 หลายเดือนก่อน +3

      I actually love how snappy it is, to the point
      You can reduce speed and I sometimes rewind and/or pause when I feel I need a better look at a particular part of the video