json-schema icon indicating copy to clipboard operation
json-schema copied to clipboard

[Question] Is there a way to generate error output?

Open JeroenDeDauw opened this issue 3 years ago • 2 comments

I am aware that the ValidationResult returned by validate() can contain a ValidationError.

Does this library provide a way to turn a ValidationError into an error text that can be shown to the user? Looks like generating such a message is somewhat involved, with ValidationError containing multiple potentially relevant fields, including subErrors. So I rather not reinvent the wheel here.

For my use cases this message does not need to be fancy or particularly user friendly. Something akin to a stack trace would work great and is miles better than just dumping a serialized version of ValidationError.

JeroenDeDauw avatar Mar 13 '22 13:03 JeroenDeDauw

Something similar to https://www.php.net/manual/en/throwable.gettraceasstring.php

JeroenDeDauw avatar Apr 20 '22 11:04 JeroenDeDauw

https://opis.io/json-schema/2.x/php-error-formatter.html

sorinsarca avatar Apr 21 '22 04:04 sorinsarca