nette / schema

📐 Validating data structures against a given Schema.
https://doc.nette.org/schema
Other
886 stars 26 forks source link

Programmatically access path of field(s) with error(s) #33

Closed repli2dev closed 3 years ago

repli2dev commented 3 years ago

I believe it is not so uncommon to use such library when validating API parameters which is inherently connected to reporting errors back to the caller.

In such situation it is not uncommon to provide path* within the request payload and nette/schema does that in way that is not directly usable to be passed back to the response as it is available only (as far as I investigated) to the exception message.

So it would be nice to be able to access the path programmatically.

dg commented 3 years ago

Method $e->getMessages() returns array of all message strings and $e->getMessageObjects() return all messages as Nette\Schema\Message objects and there is path property.

repli2dev commented 3 years ago

Tested on master and it seems to work nice! Good job :-) Closing as this is suitable now for our purpose.