Łukasz Lalik
Sep 2, 2018 · 1 min read

Hey, thanks for your comment!

I implemented this errors formatting in 2 programming languages — Python and PHP.

For python I used Cerberus validation library (http://docs.python-cerberus.org/). It allows to implement custom Error Handlers which are responsible for formatting errors. Thanks that you can easily output errors in exactly the same format as I described in the article. Probably I could open source this formatter that we created for our needs.

In PHP I used Symfony Validation (https://symfony.com/doc/3.4/validation.html). Its validate() method returns object that implements ConstraintViolationListInterface. You can use it to iterate over every ConstraintViolation object. This objects have getCode method which returns type of error and getPropertyPath method which returns path to element that caused error.