mirror of
https://github.com/grassrootseconomics/cic-custodial.git
synced 2024-11-24 23:06:47 +01:00
23 lines
404 B
Go
23 lines
404 B
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/go-playground/validator"
|
|
"github.com/labstack/echo/v4"
|
|
)
|
|
|
|
type Validator struct {
|
|
ValidatorProvider *validator.Validate
|
|
}
|
|
|
|
func (v *Validator) Validate(i interface{}) error {
|
|
if err := v.ValidatorProvider.Struct(i); err != nil {
|
|
return echo.NewHTTPError(http.StatusBadRequest, ErrResp{
|
|
Ok: false,
|
|
Code: VALIDATION_ERROR,
|
|
})
|
|
}
|
|
return nil
|
|
}
|