Skip to content

Commit

Permalink
Unify placeholders in documentation and code
Browse files Browse the repository at this point in the history
  • Loading branch information
aivus authored Jan 19, 2017
1 parent 9576bc1 commit 274ffc5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions validation/custom_constraint.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ First you need to create a Constraint class and extend :class:`Symfony\\Componen
*/
class ContainsAlphanumeric extends Constraint
{
public $message = 'The string "%string%" contains an illegal character: it can only contain letters or numbers.';
public $message = 'The string "{{ string }}" contains an illegal character: it can only contain letters or numbers.';
}

.. note::
Expand Down Expand Up @@ -67,14 +67,14 @@ The validator class is also simple, and only has one required method ``validate(
if (!preg_match('/^[a-zA-Z0-9]+$/', $value, $matches)) {
// If you're using the new 2.5 validation API (you probably are!)
$this->context->buildViolation($constraint->message)
->setParameter('%string%', $value)
->setParameter('{{ string }}', $value)
->addViolation();

// If you're using the old 2.4 validation API
/*
$this->context->addViolation(
$constraint->message,
array('%string%' => $value)
array('{{ string }}' => $value)
);
*/
}
Expand Down

0 comments on commit 274ffc5

Please sign in to comment.