Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Validator] Make ExpressionLanguageSyntax validator usable with annotation #36886

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
May 22, 2020

Conversation

jderusse
Copy link
Member

Q A
Branch? master
Bug fix? yes
New feature? no
Deprecations? no
Tickets NA
License MIT
Doc PR NA

When using the new on an entity ExpressionLanguageSyntax (basicaly copy/pasted the sample from https://symfony.com/blog/new-in-symfony-5-1-expressionlanguage-validator), I face a first error:

Constraint validator "" does not exist or is not enabled. Check the "validatedBy" method in your constraint class "Symfony\Component\Validator\Constraints\ExpressionLanguageSyntax".

indeed, the service is need to generate a valide alias

Which looks weird for a Constraint

This PR makes the ExpressionLanguage dependency optionnal in ExpressionLanguageSyntaxValidator, and removes the service than is not needed anyore

@jderusse
Copy link
Member Author

ping @Andrej-in-ua

@@ -52,4 +52,13 @@ public function validate($expression, Constraint $constraint): void
->addViolation();
}
}

private function getExpressionLanguage(): ExpressionLanguage
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inspired from

private function getExpressionLanguage(): ExpressionLanguage
{
if (null === $this->expressionLanguage) {
$this->expressionLanguage = new ExpressionLanguage();
}
return $this->expressionLanguage;
}

@xabbuh xabbuh added this to the 5.1 milestone May 21, 2020
@fabpot fabpot changed the base branch from master to 5.1 May 22, 2020 17:13
@fabpot
Copy link
Member

fabpot commented May 22, 2020

Thank you @jderusse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.