Skip to content

Custom Validator cookbook entry wrong #1333

@lewisbassett

Description

@lewisbassett

http://symfony.com/doc/current/cookbook/validation/custom_constraint.html#class-constraint-validator

In the section for Class Constraint Validator, the method addViolationAtSubPath() is used.

It doesn't exist any more.

Instead, you should show:

$propertyPath = $this->context->getPropertyPath() . 'foo';
$this->context->setPropertyPath($propertyPath);
$this->context->addViolation($constraint->getMessage(), array(), null);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions