How to Get ValidationError back from Validate? #131
-
I think I'm being really silly, but I cannot for the life of me work out how to get a ValidationError returned from the Validate function. Every time it returns a normal Error, and the signature on the function says it only returns Error. I've tried:
and my IDE just complains that Validate doesn't return a ValidationError type. How do I get this to work properly? Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
in golang, function signature always will have var err = schema.Validate(f)
if verr, ok = err.(*jsonschema.ValidationError); ok {
fmt.Println(verr.InstanceLocation)
} |
Beta Was this translation helpful? Give feedback.
-
I was able to resolve this issue with:
|
Beta Was this translation helpful? Give feedback.
in golang, function signature always will have
error
. you have to check for specific error type as shown below: