ConstraintViolationInterface

ConstraintViolationInterface

interface ConstraintViolationInterface

A violation of a constraint that happened during validation.

For each constraint that fails during validation one or more violations are created. The violations store the violation message, the path to the failing element in the validation graph and the root element that was originally passed to the validator. For example, take the following graph:

(Person)---(firstName: string)
     \
  (address: Address)---(street: string)

If the Person object is validated and validation fails for the "firstName" property, the generated violation has the Person instance as root and the property path "firstName". If validation fails for the "street" property of the related Address instance, the root element is still the person, but the property path is "address.street".

Methods

登录查看完整内容