20 lines
265 B
Go
20 lines
265 B
Go
|
package validator
|
||
|
|
||
|
import (
|
||
|
"github.com/go-playground/validator/v10"
|
||
|
)
|
||
|
|
||
|
var (
|
||
|
v = validator.New()
|
||
|
)
|
||
|
|
||
|
func Struct(val any) error {
|
||
|
return v.Struct(val)
|
||
|
}
|
||
|
|
||
|
func init() {
|
||
|
_ = v.RegisterValidation("optional", func(f validator.FieldLevel) bool {
|
||
|
return true
|
||
|
})
|
||
|
}
|