mirror of
https://github.com/grassrootseconomics/cic-custodial.git
synced 2024-11-22 22:26:46 +01:00
19 lines
385 B
Go
19 lines
385 B
Go
package api
|
|
|
|
import (
|
|
"github.com/go-playground/validator/v10"
|
|
)
|
|
|
|
type Validator struct {
|
|
ValidatorProvider *validator.Validate
|
|
}
|
|
|
|
func (v *Validator) Validate(i interface{}) error {
|
|
if err := v.ValidatorProvider.Struct(i); err != nil {
|
|
if _, ok := err.(validator.ValidationErrors); ok {
|
|
return NewBadRequestError(err.(validator.ValidationErrors).Error())
|
|
}
|
|
}
|
|
return nil
|
|
}
|