Skip to content

Commit 97c8bdf

Browse files
committed
feature #39327 [FrameworkBundle] Add validator.expression_language service (fbourigault)
This PR was squashed before being merged into the 5.3-dev branch. Discussion ---------- [FrameworkBundle] Add validator.expression_language service | Q | A | ------------- | --- | Branch? | 5.x | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | | License | MIT | Doc PR | This add a `validator.expression_language` service to allow better than in-memory caching of validation expression. This also opens possibilities to extend the expression language available in validation expression through the use of `ExpressionFunctionProviderInterface` and a compiler pass. I tried to do something close as what exists for `security.expression_language` service but I still have some questions. - Which kind of tests should I write for this feature? - Does it deserve having it's own child `ExpressionLanguage` class? #SymfonyHackday Commits ------- 41c5901047 [FrameworkBundle] Add validator.expression_language service
2 parents ee89df3 + 257e899 commit 97c8bdf

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Resources/config/validator.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Bundle\FrameworkBundle\CacheWarmer\ValidatorCacheWarmer;
1515
use Symfony\Component\Cache\Adapter\PhpArrayAdapter;
16+
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
1617
use Symfony\Component\Validator\Constraints\EmailValidator;
1718
use Symfony\Component\Validator\Constraints\ExpressionValidator;
1819
use Symfony\Component\Validator\Constraints\NotCompromisedPasswordValidator;
@@ -66,10 +67,18 @@
6667
])
6768

6869
->set('validator.expression', ExpressionValidator::class)
70+
->args([service('validator.expression_language')->nullOnInvalid()])
6971
->tag('validator.constraint_validator', [
7072
'alias' => 'validator.expression',
7173
])
7274

75+
->set('validator.expression_language', ExpressionLanguage::class)
76+
->args([service('cache.validator_expression_language')->nullOnInvalid()])
77+
78+
->set('cache.validator_expression_language')
79+
->parent('cache.system')
80+
->tag('cache.pool')
81+
7382
->set('validator.email', EmailValidator::class)
7483
->args([
7584
abstract_arg('Default mode'),

0 commit comments

Comments
 (0)