System (please complete the following information):
- OS:
macOS [e.g. linux, macOS]
- GO Version:
1.25.0 [e.g. 1.13]
- Pkg Version:
1.4.5 (before), 1.5.6 (after)
Describe the bug
I have some scenes where in some cases I specifically do not want to validate anything.
Previously on v1.4.5 these worked, but after updating to v1.5.6 I am now encountering validation failures when in scenes that should have no validation.
To Reproduce
Minimum reproducible example on Go Playground here!
My struct and validation scenes look like this:
type MyStruct struct {
SubStruct *SubStruct `validate:"required"`
}
type SubStruct struct {
A string
}
func (MyStruct) ConfigValidation(v *validate.Validation) {
v.WithScenes(validate.SValues{
"SubStruct": []string{"SubStruct"},
"None": []string{""}, // Don't validate anything in this case
})
}
And I am validating like this:
foo := MyStruct{}
if err := validate.Struct(&foo).ValidateE("None"); err != nil {
log.Panicf("Validation error: %v", err)
}
Expected behavior
Previously, in this scenario, no validation rules would be applied, and it would be permitted that SubStruct was unpopulated. No error would be raised.
Now after the update, it fails with:
Validation error: required: SubStruct is required to not be empty
System (please complete the following information):
macOS[e.g. linux, macOS]1.25.0[e.g.1.13]1.4.5(before),1.5.6(after)Describe the bug
I have some scenes where in some cases I specifically do not want to validate anything.
Previously on v1.4.5 these worked, but after updating to v1.5.6 I am now encountering validation failures when in scenes that should have no validation.
To Reproduce
Minimum reproducible example on Go Playground here!
My struct and validation scenes look like this:
And I am validating like this:
Expected behavior
Previously, in this scenario, no validation rules would be applied, and it would be permitted that SubStruct was unpopulated. No error would be raised.
Now after the update, it fails with: