RicoSuter / NJsonSchema

JSON Schema reader, generator and validator for .NET
http://NJsonSchema.org
MIT License
1.37k stars 529 forks source link

Expose failing JToken in ValidationError #1692

Closed ouvreboite closed 2 months ago

ouvreboite commented 4 months ago

Hi there. A very small PR that would greatly improve how I can post-process validation errors 🙂

Exposing the JToken that failed the error will allow NJsonSchema users to access various information, including the actual content of the failed token.

For example, when you have a "StringExpected" error, you can quickly access ValidationError.Token to see what is the actual value that is not a string. Especially handy for investigating non-nullable field that received a null value.