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

Unify placeholders in documentation and code #7390

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 15, 2017
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
8000
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