mirror of
https://github.com/datarhei/core.git
synced 2025-09-27 04:16:25 +08:00
24 lines
417 B
Go
24 lines
417 B
Go
package validator
|
|
|
|
import (
|
|
"github.com/go-playground/validator/v10"
|
|
"github.com/labstack/echo/v4"
|
|
)
|
|
|
|
type jsonValidator struct {
|
|
validator *validator.Validate
|
|
}
|
|
|
|
// New returns a new Validator for the echo webserver framework
|
|
func New() echo.Validator {
|
|
v := &jsonValidator{
|
|
validator: validator.New(),
|
|
}
|
|
|
|
return v
|
|
}
|
|
|
|
func (cv *jsonValidator) Validate(i interface{}) error {
|
|
return cv.validator.Struct(i)
|
|
}
|