You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// data.Product
type Product struct {
ID int `json:"id"` // Unique identifier for the product
Name string `json:"name" validate:"required"`
Description string `json:"description"`
SKU string `json:"sku" validate:"sku"`
}
Could it be the version 10 from go validator has broken the implementation? I have cloned your repo and checked out episode_7 branch and it throws the above error for valid requests.
The text was updated successfully, but these errors were encountered:
// Refer: https://github.com/go-playground/validator/issues/632
func (v *Validation) Validate(i interface{}) ValidationErrors {
var returnErrs []ValidationError
if errs, ok := v.validate.Struct(i).(validator.ValidationErrors); ok {
if errs != nil {
for _, err := range errs {
if fe, ok := err.(validator.FieldError); ok {
ve := ValidationError{fe}
returnErrs = append(returnErrs, ve)
}
}
}
}
return returnErrs
}
Issue
The below validator works for invalid request body, but for a valid body, it initiates a
panic
Code sample, to showcase or reproduce:
data/validation.go
handlers/post.go
:data/products.go
Stack Trace:
Could it be the version 10 from go validator has broken the implementation? I have cloned your repo and checked out
episode_7
branch and it throws the above error for valid requests.The text was updated successfully, but these errors were encountered: