Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c4db134

Browse files
[FrameworkBundle][DX] Allow to avoid limit definition in a RateLimiter configuration when using the no_limit policy
1 parent e113442 commit c4db134

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2014,7 +2014,6 @@ private function addRateLimiterSection(ArrayNodeDefinition $rootNode, callable $
20142014
->end()
20152015
->integerNode('limit')
20162016
->info('The maximum allowed hits in a fixed interval or burst')
2017-
->isRequired()
20182017
->end()
20192018
->scalarNode('interval')
20202019
->info('Configures the fixed interval if "policy" is set to "fixed_window" or "sliding_window". The value must be a number followed by "second", "minute", "hour", "day", "week" or "month" (or their plural equivalent).')
@@ -2029,6 +2028,10 @@ private function addRateLimiterSection(ArrayNodeDefinition $rootNode, callable $
20292028
->end()
20302029
->end()
20312030
->end()
2031+
->validate()
2032+
->ifTrue(function ($v) { return 'no_limit' !== $v['policy'] && null === ($v['limit'] ?? null); })
2033+
->thenInvalid('A limit must be provided when using a policy different than "no_limit".')
2034+
->end()
20322035
->end()
20332036
->end()
20342037
->end()

0 commit comments

Comments
 (0)