From 760245423e04c70da9bb7df5202ba5c525d14370 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sun, 1 Feb 2015 16:46:51 +0100 Subject: [PATCH] [Validator] use 2.5 API in LengthValidator --- .../Component/Validator/Constraints/LengthValidator.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Validator/Constraints/LengthValidator.php b/src/Symfony/Component/Validator/Constraints/LengthValidator.php index 0634b4f476..7d97e19e02 100644 --- a/src/Symfony/Component/Validator/Constraints/LengthValidator.php +++ b/src/Symfony/Component/Validator/Constraints/LengthValidator.php @@ -64,10 +64,11 @@ class LengthValidator extends ConstraintValidator } if ($invalidCharset) { - $this->context->addViolation($constraint->charsetMessage, array( - '{{ value }}' => $this->formatValue($stringValue), - '{{ charset }}' => $constraint->charset, - ), $value); + $this->buildViolation($constraint->charsetMessage) + ->setParameter('{{ value }}', $this->formatValue($stringValue)) + ->setParameter('{{ charset }}', $constraint->charset) + ->setInvalidValue($value) + ->addViolation(); return; }