File tree 1 file changed +19
-0
lines changed
1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -382,6 +382,25 @@ a new ``locale`` parameter is added to the ``config/services.yaml`` file).
382
382
They are useful when working with :ref: `Compiler Passes </service_container/compiler_passes >`
383
383
to declare some temporary parameters that won't be available later in the application.
384
384
385
+ Configuration parameters are usually validation-free, but you can ensure that
386
+ essential parameters for your application's functionality are not empty::
387
+
388
+ // ContainerBuilder
389
+ $container->parameterCannotBeEmpty('app.private_key', 'Did you forget to configure a non-empty value for "app.private_key" parameter?');
390
+
391
+ If a non-empty parameter is empty (e.g. ``null ``, an empty string ``'' ``, or an empty
392
+ array ``[] ``), Symfony will throw an exception with the custom error message when
393
+ attempting to retrieve the value of this parameter.
394
+
395
+ .. versionadded :: 7.2
396
+
397
+ Validating non-empty parameters was introduced in Symfony 7.2.
398
+
399
+ .. note ::
400
+
401
+ Please note that this validation will *only * occur if a non-empty parameter value
402
+ is retrieved; otherwise, no exception will be thrown.
403
+
385
404
.. seealso ::
386
405
387
406
Later in this article you can read how to
You can’t perform that action at this time.
0 commit comments