-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Description
- I have looked at the documentation here first?
- I have looked at the examples provided that may showcase my question here?
Package version: v10.15.0
Issue:
The behavior or required tag with empty structures was changed. In v10.14.1 the code below passes validation just fine.
Starting from version v10.15.0 it fails with error:
Key: 'OuterType.Component' Error:Field validation for 'Component' failed on the 'required' tag
It would be nice not to break backward compatibility. I know that this is a rare case, but we currently have problems with some autogenerated code. This is also a possible issue for some usecases of go generics.
Code sample, to showcase or reproduce:
func TestRequiredEmptyComponent(t *testing.T) {
v := validator.New()
type Component struct{}
type OuterType struct {
Component Component `validate:"required"`
Other int
}
var val OuterType = OuterType{
Component: Component{},
Other: 1,
}
if err := v.Struct(val); err != nil {
t.Error(err)
}
}o98k-ok
Metadata
Metadata
Assignees
Labels
No labels