Issue Feature Closed

#93835Attribute validation errors to sub properties in custom validators

Volker Diels-Grabsch 03/30/21, 21:03 updated 09/07/21, 07:34

Description

For complex validators, it often makes sense that a custom validator can attribute an error to a specific property or sub property, even though it is validating a whole class.

This is already possible by accessing a validator’s $this->result directly, but that is cumbersome and in no way obvious, as this requires deep knowledge of the Result and Error classes.

So there should be a convenience method “addErrorForProperty” similar to “addError” that takes a property path in addition to the error details (message, code, etc.).

Reviews 3