mirror of
https://github.com/grassrootseconomics/cic-custodial.git
synced 2024-11-22 22:26:46 +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
|
|
}
|