Initial commit
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package web_gin
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin/binding"
|
||||
"pet-house.com/core/server/web"
|
||||
)
|
||||
|
||||
func registerValidation() {
|
||||
if v, ok := binding.Validator.Engine().(*validator.Validate); ok {
|
||||
v.RegisterValidation("dev-required", validateDevRequired)
|
||||
}
|
||||
}
|
||||
|
||||
var validateDevRequired validator.Func = func(fl validator.FieldLevel) bool {
|
||||
if web.CONFIG.System.Level == "release" {
|
||||
return fl.Field().String() != ""
|
||||
}
|
||||
return true
|
||||
}
|
||||
Reference in New Issue
Block a user