What's changed
BindJSON — opt-in required validation
Fields are now optional by default. Mark a field required with the pine:"required" tag:
type CreateUserRequest struct {
Name string `json:"name" pine:"required"` // must be non-empty
Email string `json:"email" pine:"required"` // must be non-empty
Tags []string `json:"tags"` // optional — empty slice accepted
Age int `json:"age"` // optional — zero accepted
}
if err := c.BindJSON(req); err != nil {
// only fires if a pine:"required" field is missing or empty
}Migration
Add pine:"required" to any field that must be present. Fields with
// Before (all fields implicitly required)
type Body struct {
Name string `json:"name"`
}
// After (opt in explicitly)
type Body struct {
Name string `json:"name" pine:"required"`
}Full changelog: https://github.com/BryanMwangi/pine/blob/main/CHANGELOG.md