xeipuuv / gojsonschema

An implementation of JSON Schema, draft v4 v6 & v7 - Go language
2.56k stars 358 forks source link

Add JsonPointer method to resulterror #83

Open nickcarenza opened 9 years ago

nickcarenza commented 9 years ago

This would be convenient instead of having to use the dot-separated value returned by the Field() method of ResultErrorFields.

example:

res, err := gojsonschema.Validate(schemaLoader, jsonLoader)
for _, resErr := range res.Errors() {
    resErr.Field() // -> search.name
    resErr.JSONPointer() // -> /search/name
}

If this is a good idea, I would be happy to implement the feature.

neumachen commented 8 years ago

It's a good idea and the error is compliant with jsonapi.org when building the Error object's source field.