Open brpaz opened 3 years ago
v10
Hello. I am trying to define a custom validator in a multipart.FileHeader type to validate file type and size, but it´s not being called.
type CreateTeamDto struct { Name string `form:"name" validate:"required"` Logo *multipart.FileHeader `form:"logo" validate:"required,filetype"` }
Validator Definition
import ( goValidator "github.com/go-playground/validator/v10" ) validator := goValidator.New() validator.RegisterValidation("filetype", FileTypeValidator, true) func FileTypeValidator(fl validator.FieldLevel) bool { fmt.Println("file type validator!!!!!!!!!!!") return false }
The required validation works. And If I use this validator in other field in also works. But on the *multipart.FileHeader the function is never called.
Following, running into a similar issue.
I got around my issue with RegisterStructValidation
RegisterStructValidation
+1. Any follow-up?
https://github.com/go-playground/validator/issues/470#issuecomment-487990618
Package version eg. v9, v10:
v10
Issue, Question or Enhancement:
Hello. I am trying to define a custom validator in a multipart.FileHeader type to validate file type and size, but it´s not being called.
Code sample, to showcase or reproduce:
Validator Definition
The required validation works. And If I use this validator in other field in also works. But on the *multipart.FileHeader the function is never called.