8000 Unify placeholders in documentation and code by aivus · Pull Request #7390 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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