From c510abb1704b90fc017ef9a8ba2a5dd8c4f5e4e8 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 4 Jul 2019 12:25:41 +0200 Subject: [PATCH] [Validator] Documented the allowEmptyString option in Length --- reference/constraints/Length.rst | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/reference/constraints/Length.rst b/reference/constraints/Length.rst index 88ef1040b70..fb56d8070d2 100644 --- a/reference/constraints/Length.rst +++ b/reference/constraints/Length.rst @@ -3,15 +3,10 @@ Length Validates that a given string length is *between* some minimum and maximum value. -.. caution:: - - ``null`` and empty strings are not handled by this constraint. You need to - also add the :doc:`/reference/constraints/NotBlank` or :doc:`/reference/constraints/NotNull` - constraints to validate against these. - ========== =================================================================== Applies to :ref:`property or method ` -Options - `charset`_ +Options - `allowEmptyString`_ + - `charset`_ - `charsetMessage`_ - `exactMessage`_ - `groups`_ @@ -115,6 +110,20 @@ and "50", you might add the following: Options ------- +allowEmptyString +~~~~~~~~~~~~~~~~ + +**type**: ``boolean`` **default**: ``true`` + +.. versionadded:: 4.4 + + The ``allowEmptyString`` option was introduced in Symfony 4.4. + +When using the ``min`` option, it's mandatory to also define this option. If +set to ``true``, empty strings are considered valid (which is the same behavior +as previous Symfony versions). Set it to ``false`` to consider empty strings not +valid. + charset ~~~~~~~