package main
import (
"fmt"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gctx"
)
type SearchReq struct {
Key string `v:"required"`
Option SearchOption
}
type SearchOption struct {
Page int `v:"min:1"`
Size int `v:"max:100"`
}
func main() {
var (
ctx = gctx.New()
req = SearchReq{
Key: "GoFrame",
Option: SearchOption{
Page: 1,
Size: 10000,
},
}
)
err := g.Validator().Data(req).Run(ctx)
fmt.Println(err)
}