mirror of
https://github.com/grassrootseconomics/cic-custodial.git
synced 2024-12-22 17:57:32 +01:00
25 lines
430 B
Go
25 lines
430 B
Go
package api
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"github.com/go-playground/validator"
|
|
"github.com/labstack/echo/v4"
|
|
)
|
|
|
|
type CustomValidator struct {
|
|
Validator *validator.Validate
|
|
}
|
|
|
|
func (cv *CustomValidator) Validate(i interface{}) error {
|
|
if err := cv.Validator.Struct(i); err != nil {
|
|
fmt.Println(err)
|
|
return echo.NewHTTPError(http.StatusBadRequest, errResp{
|
|
Ok: false,
|
|
Error: VALIDATION_ERROR,
|
|
})
|
|
}
|
|
return nil
|
|
}
|