Skip to content

Commit

Permalink
documenting non-empty parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
yceruto committed Sep 23, 2024
1 parent 3983e81 commit f2ca84e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,25 @@ a new ``locale`` parameter is added to the ``config/services.yaml`` file).
They are useful when working with :ref:`Compiler Passes </service_container/compiler_passes>`
to declare some temporary parameters that won't be available later in the application.

Configuration parameters are usually validation-free, but you can ensure that
essential parameters for your application's functionality are not empty::

// ContainerBuilder
$container->parameterCannotBeEmpty('app.private_key', 'Did you forget to configure a non-empty value for "app.private_key" parameter?');

If a non-empty parameter is empty (e.g. ``null``, an empty string ``''``, or an empty
array ``[]``), Symfony will throw an exception with the custom error message when
attempting to retrieve the value of this parameter.

.. versionadded:: 7.2

Validating non-empty parameters was introduced in Symfony 7.2.

.. note::

Please note that this validation will *only* occur if a non-empty parameter value
is retrieved; otherwise, no exception will be thrown.

.. seealso::

Later in this article you can read how to
Expand Down

0 comments on commit f2ca84e

Please sign in to comment.