minor #13568 [Validator] use 2.5 API in LengthValidator (nicolas-grekas)

This PR was merged into the 2.5 branch.

Discussion
----------

[Validator] use 2.5 API in LengthValidator

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Commits
-------

7602454 [Validator] use 2.5 API in LengthValidator
This commit is contained in:
Nicolas Grekas 2015-02-01 17:05:01 +01:00
commit ed18cde58d
1 changed files with 5 additions and 4 deletions

View File

@ -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;
}