Skip to content

[Validator] Possible bug when formatting constraint violation #10675

Closed
@dnohales

Description

@dnohales

In the class Symfony\Component\Validator\Constraints\AbstractComparisonValidator I am suspecting that the constraint message is not being properly parametrized. Check the validate method of that class:

public function validate($value, Constraint $constraint)
{
    if (!$constraint instanceof AbstractComparison) {
        throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\AbstractComparison');
    }

    if (null === $value) {
        return;
    }

    if (!$this->compareValues($value, $constraint->value)) {
        $this->context->addViolation($constraint->message, array(
            '{{ value }}' => $this->valueToString($constraint->value),
            '{{ compared_value }}' => $this->valueToString($constraint->value),
            '{{ compared_value_type }}' => $this->valueToType($constraint->value)
        ));
    }
}

It's like {{ value }} should be the value that is being compared, namely, $value variable. Am I wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions