cic-custodial/internal/api/validator.go
Mohammed Sohail 2ca0d23c3c
feat: add transfer handler and input validation
* validate incoming api requests
* fix transfer ABI encoder
2022-11-30 15:18:01 +00:00

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
}