MustValidate
Overview
MustValidate panics if validation fails.
Part of the validate package — Node.js analog: zod, joi.
Signature
go
func MustValidate(v any)Compare: Node.js · Standard Go · gox
js
// Typical zod, joi pattern in Node.jsgo
// use github.com/go-playground/validator struct tags or manual checksgo
import "github.com/sahilkhaire/gox/validate"
validate.MustValidate(signup{Email: "a@b.com", Age: 21})Example
go
import "github.com/sahilkhaire/gox/validate"
validate.MustValidate(signup{Email: "a@b.com", Age: 21})Tips
Import github.com/sahilkhaire/gox/validate and call MustValidate directly. See the comparison below for the standard library equivalent.
Standard library alternative
gox wraps the Go standard library or a trusted dependency with Node-familiar naming. You can use the underlying library directly — see the package overview for escape hatches.