Closed jonasknobloch closed 4 years ago
package main
import (
"fmt"
"github.com/go-ozzo/ozzo-validation"
)
type Foo string
type Bar struct {
A string
B Foo
}
func (f Foo) Validate() error {
return validation.Validate(string(f),
validation.Required,
)
}
func (b Bar) Validate() error {
return validation.ValidateStruct(&b,
validation.Field(
&b.A,
validation.Required,
),
validation.Field(&b.B),
)
}
func main() {
var foo Foo = ""
bar := Bar{"bar", foo}
fmt.Println(bar.Validate())
}
Doing a type conversion back to string
works.
Some clarification if this is intended would be appreciated.
Please see the commit for an explanation. Thanks for reporting the issue.
example
When validating the struct with validation.ValidateStruct, validation dives into the
Foo
field and gets trapped in an infinite loop. Not sure if I misinterpreted the docs though. Some clarification if this is intended would be appreciated.