In my app I use validator.v9 to validate my model. After validation I can cast the error interface and it\'s successes, I see \'OK\' on the console
Your errValidation type and the validator.ValidationErrors type are completely different, distinct types. If an interface value holds a value of concrete type errValidation, you can't type assert another concrete type from it, only errValidation.
So this will work:
e := ValidationError(errors.New("some err"))
if _, ok := e.(errValidation); ok {
fmt.Println("ValidationError: OK")
} else {
fmt.Println("ValidationError: FALSE")
}
And output will be (try it on the Go Playground):
ValidationError: OK