review changes

This commit is contained in:
tsmethurst 2021-09-03 11:12:19 +02:00
parent a116676814
commit 32fe2282c4

View file

@ -27,11 +27,6 @@
var v *validator.Validate var v *validator.Validate
// Validation Panic messages
const (
InvalidPanic = "validate function was passed invalid item"
)
func ulidValidator(fl validator.FieldLevel) bool { func ulidValidator(fl validator.FieldLevel) bool {
field := fl.Field() field := fl.Field()
@ -52,13 +47,7 @@ func init() {
// Struct validates the passed struct, returning validator.ValidationErrors if invalid, or nil if OK. // Struct validates the passed struct, returning validator.ValidationErrors if invalid, or nil if OK.
func Struct(s interface{}) error { func Struct(s interface{}) error {
switch reflect.TypeOf(s).Kind() { return processValidationError(v.Struct(s))
case reflect.Invalid:
panic(InvalidPanic)
}
err := v.Struct(s)
return processValidationError(err)
} }
func processValidationError(err error) error { func processValidationError(err error) error {