Errors and Form Validations Guidelines
fmt.Errorf("...: %w")
.system/errors.go
). The handler then unwraps the error and, based on the type, applies the proper logic.system.ErrValidation
with the appropriate error code:
try / catch
that forces you to handle errors. It aims to mimic what Go or Rust do (tries, JS error handling sucks).Safe
, and you can find its logic in safe.ts
file. For more information, please check the article: Typescript with Go/Rust Errors: No Try/Catch Heresyrequired
, maxlength
), while more advanced validations are handled by the server.
When the server sends a proper status code, the frontend unwraps the message, assigns it to the fields
object, and passes it down to the pages.
The page then extracts the errors and displays it on the form.zod
library for client-side validation.
The Edit Note
page is the only one that showcases this flow.
It works similarly to the Full Server-Side approach, with the exception that zod
handles input validation first and then passes the fields
object down.
Of course, the server must still perform its full validation.