diff --git a/reference/constraints/All.rst b/reference/constraints/All.rst index 5cdd5f9d45b..48dddc39f32 100644 --- a/reference/constraints/All.rst +++ b/reference/constraints/All.rst @@ -4,17 +4,14 @@ All When applied to an array (or Traversable object), this constraint allows you to apply a collection of constraints to each element of the array. -+----------------+-------------------------------------------------------------------+ -| Applies to | :ref:`property or method ` | -+----------------+-------------------------------------------------------------------+ -| Options | - `constraints`_ | -| | - `groups`_ | -| | - `payload`_ | -+----------------+-------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\All` | -+----------------+-------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\AllValidator` | -+----------------+-------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `constraints`_ + - `groups`_ + - `payload`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\All` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\AllValidator` +========== =================================================================== Basic Usage ----------- diff --git a/reference/constraints/Bic.rst b/reference/constraints/Bic.rst index 1a30dbf50cf..49060cf5f64 100644 --- a/reference/constraints/Bic.rst +++ b/reference/constraints/Bic.rst @@ -6,20 +6,17 @@ This constraint is used to ensure that a value has the proper format of a uniquely identify both financial and non-financial institutions. You may also check that the BIC is associated with a given IBAN. -+----------------+-----------------------------------------------------------------------+ -| Applies to | :ref:`property or method ` | -+----------------+-----------------------------------------------------------------------+ -| Options | - `groups`_ | -| | - `message`_ | -| | - `payload`_ | -| | - `iban`_ | -| | - `ibanMessage`_ | -| | - `ibanPropertyPath`_ | -+----------------+-----------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Bic` | -+----------------+-----------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\BicValidator` | -+----------------+-----------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `groups`_ + - `iban`_ + - `ibanMessage`_ + - `ibanPropertyPath`_ + - `message`_ + - `payload`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\Bic` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\BicValidator` +========== =================================================================== Basic Usage ----------- @@ -92,23 +89,6 @@ Available Options .. include:: /reference/constraints/_groups-option.rst.inc -message -~~~~~~~ - -**type**: ``string`` **default**: ``This is not a valid Business Identifier Code (BIC).`` - -The default message supplied when the value does not pass the BIC check. - -You can use the following parameters in this message: - -+------------------+------------------------------------------------+ -| Parameter | Description | -+==================+================================================+ -| ``{{ value }}`` | The current (invalid) BIC value | -+------------------+------------------------------------------------+ - -.. include:: /reference/constraints/_payload-option.rst.inc - iban ~~~~ @@ -134,4 +114,21 @@ For example, if you want to compare the ``$bic`` property of some object with regard to the ``$iban`` property of the same object, use ``propertyPath="iban"`` in the comparison constraint of ``$bic``. +message +~~~~~~~ + +**type**: ``string`` **default**: ``This is not a valid Business Identifier Code (BIC).`` + +The default message supplied when the value does not pass the BIC check. + +You can use the following parameters in this message: + +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ value }}`` The current (invalid) BIC value +=============== ============================================================== + +.. include:: /reference/constraints/_payload-option.rst.inc + .. _`Business Identifier Code (BIC)`: https://en.wikipedia.org/wiki/Business_Identifier_Code diff --git a/reference/constraints/Blank.rst b/reference/constraints/Blank.rst index 596c2a11a7c..f1dddb5a75d 100644 --- a/reference/constraints/Blank.rst +++ b/reference/constraints/Blank.rst @@ -13,17 +13,14 @@ To force that a value strictly be equal to ``null``, see the To force that a value is *not* blank, see :doc:`/reference/constraints/NotBlank`. But be careful as ``NotBlank`` is *not* strictly the opposite of ``Blank``. -+----------------+---------------------------------------------------------------------+ -| Applies to | :ref:`property or method ` | -+----------------+---------------------------------------------------------------------+ -| Options | - `groups`_ | -| | - `message`_ | -| | - `payload`_ | -+----------------+---------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Blank` | -+----------------+---------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\BlankValidator` | -+----------------+---------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `groups`_ + - `message`_ + - `payload`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\Blank` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\BlankValidator` +========== =================================================================== Basic Usage ----------- @@ -101,10 +98,10 @@ This is the message that will be shown if the value is not blank. You can use the following parameters in this message: -+------------------+------------------------------------------------+ -| Parameter | Description | -+==================+================================================+ -| ``{{ value }}`` | The current (invalid) value | -+------------------+------------------------------------------------+ +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ value }}`` The current (invalid) value +=============== ============================================================== .. include:: /reference/constraints/_payload-option.rst.inc diff --git a/reference/constraints/Callback.rst b/reference/constraints/Callback.rst index cd31b4ed572..c53a7c957e5 100644 --- a/reference/constraints/Callback.rst +++ b/reference/constraints/Callback.rst @@ -17,17 +17,14 @@ can do anything, including creating and assigning validation errors. as you'll see in the example, a callback method has the ability to directly add validator "violations". -+----------------+------------------------------------------------------------------------+ -| Applies to | :ref:`class ` | -+----------------+------------------------------------------------------------------------+ -| Options | - :ref:`callback ` | -| | - `groups`_ | -| | - `payload`_ | -+----------------+------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Callback` | -+----------------+------------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\CallbackValidator` | -+----------------+------------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`class ` +Options - :ref:`callback ` + - `groups`_ + - `payload`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\Callback` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\CallbackValidator` +========== =================================================================== Configuration ------------- diff --git a/reference/constraints/CardScheme.rst b/reference/constraints/CardScheme.rst index d8225e8f6ae..9cc0db7f85d 100644 --- a/reference/constraints/CardScheme.rst +++ b/reference/constraints/CardScheme.rst @@ -5,18 +5,15 @@ This constraint ensures that a credit card number is valid for a given credit card company. It can be used to validate the number before trying to initiate a payment through a payment gateway. -+----------------+--------------------------------------------------------------------------+ -| Applies to | :ref:`property or method ` | -+----------------+--------------------------------------------------------------------------+ -| Options | - `groups`_ | -| | - `schemes`_ | -| | - `message`_ | -| | - `payload`_ | -+----------------+--------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\CardScheme` | -+----------------+--------------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\CardSchemeValidator` | -+----------------+--------------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `groups`_ + - `message`_ + - `payload`_ + - `schemes`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\CardScheme` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\CardSchemeValidator` +========== =================================================================== Basic Usage ----------- @@ -104,6 +101,23 @@ Available Options .. include:: /reference/constraints/_groups-option.rst.inc +message +~~~~~~~ + +**type**: ``string`` **default**: ``Unsupported card type or invalid card number.`` + +The message shown when the value does not pass the ``CardScheme`` check. + +You can use the following parameters in this message: + +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ value }}`` The current (invalid) value +=============== ============================================================== + +.. include:: /reference/constraints/_payload-option.rst.inc + schemes ~~~~~~~ @@ -132,21 +146,4 @@ Valid values are: For more information about the used schemes, see `Wikipedia: Issuer identification number (IIN)`_. -message -~~~~~~~ - -**type**: ``string`` **default**: ``Unsupported card type or invalid card number.`` - -The message shown when the value does not pass the ``CardScheme`` check. - -You can use the following parameters in this message: - -+------------------+------------------------------------------------+ -| Parameter | Description | -+==================+================================================+ -| ``{{ value }}`` | The current (invalid) value | -+------------------+------------------------------------------------+ - -.. include:: /reference/constraints/_payload-option.rst.inc - .. _`Wikipedia: Issuer identification number (IIN)`: https://en.wikipedia.org/wiki/Bank_card_number#Issuer_identification_number_.28IIN.29 diff --git a/reference/constraints/Choice.rst b/reference/constraints/Choice.rst index 2aab9751b60..ac498d21c7e 100644 --- a/reference/constraints/Choice.rst +++ b/reference/constraints/Choice.rst @@ -5,25 +5,22 @@ This constraint is used to ensure that the given value is one of a given set of *valid* choices. It can also be used to validate that each item in an array of items is one of those valid choices. -+----------------+----------------------------------------------------------------------+ -| Applies to | :ref:`property or method ` | -+----------------+----------------------------------------------------------------------+ -| Options | - `choices`_ | -| | - `callback`_ | -| | - `groups`_ | -| | - `multiple`_ | -| | - `min`_ | -| | - `max`_ | -| | - `message`_ | -| | - `multipleMessage`_ | -| | - `minMessage`_ | -| | - `maxMessage`_ | -| | - `payload`_ | -+----------------+----------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Choice` | -+----------------+----------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\ChoiceValidator` | -+----------------+----------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `callback`_ + - `choices`_ + - `groups`_ + - `max`_ + - `maxMessage`_ + - `message`_ + - `min`_ + - `minMessage`_ + - `multiple`_ + - `multipleMessage`_ + - `payload`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\Choice` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\ChoiceValidator` +========== =================================================================== Basic Usage ----------- @@ -278,15 +275,6 @@ you can pass the class name and the method as an array. Available Options ----------------- -choices -~~~~~~~ - -**type**: ``array`` [:ref:`default option `] - -A required option (unless `callback`_ is specified) - this is the array -of options that should be considered in the valid set. The input value -will be matched against this array. - callback ~~~~~~~~ @@ -296,27 +284,16 @@ This is a callback method that can be used instead of the `choices`_ option to return the choices array. See `Supplying the Choices with a Callback Function`_ for details on its usage. -.. include:: /reference/constraints/_groups-option.rst.inc - -multiple -~~~~~~~~ - -**type**: ``boolean`` **default**: ``false`` - -If this option is true, the input value is expected to be an array instead -of a single, scalar value. The constraint will check that each value of -the input array can be found in the array of valid choices. If even one -of the input values cannot be found, the validation will fail. +choices +~~~~~~~ -min -~~~ +**type**: ``array`` [:ref:`default option `] -**type**: ``integer`` +A required option (unless `callback`_ is specified) - this is the array +of options that should be considered in the valid set. The input value +will be matched against this array. -If the ``multiple`` option is true, then you can use the ``min`` option -to force at least XX number of values to be selected. For example, if -``min`` is 3, but the input array only contains 2 valid items, the validation -will fail. +.. include:: /reference/constraints/_groups-option.rst.inc max ~~~ @@ -328,6 +305,27 @@ to force no more than XX number of values to be selected. For example, if ``max`` is 3, but the input array contains 4 valid items, the validation will fail. +maxMessage +~~~~~~~~~~ + +**type**: ``string`` **default**: ``You must select at most {{ limit }} choices.`` + +This is the validation error message that's displayed when the user chooses +too many options per the `max`_ option. + +You can use the following parameters in this message: + +================= ============================================================ +Parameter Description +================= ============================================================ +``{{ choices }}`` A comma-separated list of available choices +``{{ value }}`` The current (invalid) value +================= ============================================================ + +.. versionadded:: 4.3 + + The ``{{ choices }}`` parameter was introduced in Symfony 4.3. + message ~~~~~~~ @@ -339,28 +337,21 @@ choices. You can use the following parameters in this message: -+------------------+------------------------------------------------+ -| Parameter | Description | -+==================+================================================+ -| ``{{ value }}`` | The current (invalid) value | -+------------------+------------------------------------------------+ +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ value }}`` The current (invalid) value +=============== ============================================================== -multipleMessage -~~~~~~~~~~~~~~~ - -**type**: ``string`` **default**: ``One or more of the given values is invalid.`` - -This is the message that you will receive if the ``multiple`` option is -set to ``true`` and one of the values on the underlying array being checked -is not in the array of valid choices. +min +~~~ -You can use the following parameters in this message: +**type**: ``integer`` -+------------------+------------------------------------------------+ -| Parameter | Description | -+==================+================================================+ -| ``{{ value }}`` | The current (invalid) value | -+------------------+------------------------------------------------+ +If the ``multiple`` option is true, then you can use the ``min`` option +to force at least XX number of values to be selected. For example, if +``min`` is 3, but the input array only contains 2 valid items, the validation +will fail. minMessage ~~~~~~~~~~ @@ -372,38 +363,42 @@ too few choices per the `min`_ option. You can use the following parameters in this message: -+--------------------+-------------------------------------------------------+ -| Parameter | Description | -+====================+=======================================================+ -| ``{{ value }}`` | The current (invalid) value | -+--------------------+-------------------------------------------------------+ -| ``{{ choices }}`` | A comma-separated list of available choices | -+--------------------+-------------------------------------------------------+ +================= ============================================================ +Parameter Description +================= ============================================================ +``{{ choices }}`` A comma-separated list of available choices +``{{ value }}`` The current (invalid) value +================= ============================================================ .. versionadded:: 4.3 The ``{{ choices }}`` parameter was introduced in Symfony 4.3. -maxMessage -~~~~~~~~~~ +multiple +~~~~~~~~ -**type**: ``string`` **default**: ``You must select at most {{ limit }} choices.`` +**type**: ``boolean`` **default**: ``false`` -This is the validation error message that's displayed when the user chooses -too many options per the `max`_ option. +If this option is true, the input value is expected to be an array instead +of a single, scalar value. The constraint will check that each value of +the input array can be found in the array of valid choices. If even one +of the input values cannot be found, the validation will fail. -You can use the following parameters in this message: +multipleMessage +~~~~~~~~~~~~~~~ -+--------------------+-------------------------------------------------------+ -| Parameter | Description | -+====================+=======================================================+ -| ``{{ value }}`` | The current (invalid) value | -+--------------------+-------------------------------------------------------+ -| ``{{ choices }}`` | A comma-separated list of available choices | -+--------------------+-------------------------------------------------------+ +**type**: ``string`` **default**: ``One or more of the given values is invalid.`` -.. versionadded:: 4.3 +This is the message that you will receive if the ``multiple`` option is +set to ``true`` and one of the values on the underlying array being checked +is not in the array of valid choices. - The ``{{ choices }}`` parameter was introduced in Symfony 4.3. +You can use the following parameters in this message: + +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ value }}`` The current (invalid) value +=============== ============================================================== .. include:: /reference/constraints/_payload-option.rst.inc diff --git a/reference/constraints/Collection.rst b/reference/constraints/Collection.rst index 67bb325d5c5..53d5e59c660 100644 --- a/reference/constraints/Collection.rst +++ b/reference/constraints/Collection.rst @@ -11,21 +11,18 @@ constraint. This constraint can also make sure that certain collection keys are present and that extra keys are not present. -+----------------+--------------------------------------------------------------------------+ -| Applies to | :ref:`property or method ` | -+----------------+--------------------------------------------------------------------------+ -| Options | - `allowExtraFields`_ | -| | - `allowMissingFields`_ | -| | - `extraFieldsMessage`_ | -| | - `fields`_ | -| | - `groups`_ | -| | - `missingFieldsMessage`_ | -| | - `payload`_ | -+----------------+--------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Collection` | -+----------------+--------------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\CollectionValidator` | -+----------------+--------------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `allowExtraFields`_ + - `allowMissingFields`_ + - `extraFieldsMessage`_ + - `fields`_ + - `groups`_ + - `missingFieldsMessage`_ + - `payload`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\Collection` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\CollectionValidator` +========== =================================================================== Basic Usage ----------- @@ -319,11 +316,11 @@ detected. You can use the following parameters in this message: -+------------------+------------------------------------------------+ -| Parameter | Description | -+==================+================================================+ -| ``{{ field }}`` | The key of the extra field detected | -+------------------+------------------------------------------------+ +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ field }}`` The key of the extra field detected +=============== ============================================================== fields ~~~~~~ @@ -346,10 +343,10 @@ are missing from the underlying collection. You can use the following parameters in this message: -+------------------+----------------------------------------------------+ -| Parameter | Description | -+==================+====================================================+ -| ``{{ field }}`` | The key of the missing field defined in ``fields`` | -+------------------+----------------------------------------------------+ +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ field }}`` The key of the missing field defined in ``fields`` +=============== ============================================================== .. include:: /reference/constraints/_payload-option.rst.inc diff --git a/reference/constraints/Count.rst b/reference/constraints/Count.rst index c7aae41ce6a..7bb80face60 100644 --- a/reference/constraints/Count.rst +++ b/reference/constraints/Count.rst @@ -4,21 +4,18 @@ Count Validates that a given collection's (i.e. an array or an object that implements Countable) element count is *between* some minimum and maximum value. -+----------------+---------------------------------------------------------------------+ -| Applies to | :ref:`property or method ` | -+----------------+---------------------------------------------------------------------+ -| Options | - `min`_ | -| | - `max`_ | -| | - `minMessage`_ | -| | - `maxMessage`_ | -| | - `exactMessage`_ | -| | - `payload`_ | -| | - `groups`_ | -+----------------+---------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Count` | -+----------------+---------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\CountValidator` | -+----------------+---------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `exactMessage`_ + - `groups`_ + - `max`_ + - `maxMessage`_ + - `min`_ + - `minMessage`_ + - `payload`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\Count` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\CountValidator` +========== =================================================================== Basic Usage ----------- @@ -104,15 +101,24 @@ you might add the following: Options ------- -.. include:: /reference/constraints/_groups-option.rst.inc +exactMessage +~~~~~~~~~~~~ -min -~~~ +**type**: ``string`` **default**: ``This collection should contain exactly {{ limit }} elements.`` -**type**: ``integer`` +The message that will be shown if min and max values are equal and the underlying +collection elements count is not exactly this value. -This required option is the "min" count value. Validation will fail if the -given collection elements count is **less** than this min value. +You can use the following parameters in this message: + +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ count }}`` The current collection size +``{{ limit }}`` The exact expected collection size +=============== ============================================================== + +.. include:: /reference/constraints/_groups-option.rst.inc max ~~~ @@ -122,24 +128,6 @@ max This required option is the "max" count value. Validation will fail if the given collection elements count is **greater** than this max value. -minMessage -~~~~~~~~~~ - -**type**: ``string`` **default**: ``This collection should contain {{ limit }} elements or more.`` - -The message that will be shown if the underlying collection elements count -is less than the `min`_ option. - -You can use the following parameters in this message: - -+------------------+------------------------------------------------+ -| Parameter | Description | -+==================+================================================+ -| ``{{ count }}`` | The current collection size | -+------------------+------------------------------------------------+ -| ``{{ limit }}`` | The lower limit | -+------------------+------------------------------------------------+ - maxMessage ~~~~~~~~~~ @@ -150,30 +138,36 @@ is more than the `max`_ option. You can use the following parameters in this message: -+------------------+------------------------------------------------+ -| Parameter | Description | -+==================+================================================+ -| ``{{ count }}`` | The current collection size | -+------------------+------------------------------------------------+ -| ``{{ limit }}`` | The upper limit | -+------------------+------------------------------------------------+ +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ count }}`` The current collection size +``{{ limit }}`` The upper limit +=============== ============================================================== -exactMessage -~~~~~~~~~~~~ +min +~~~ -**type**: ``string`` **default**: ``This collection should contain exactly {{ limit }} elements.`` +**type**: ``integer`` -The message that will be shown if min and max values are equal and the underlying -collection elements count is not exactly this value. +This required option is the "min" count value. Validation will fail if the +given collection elements count is **less** than this min value. + +minMessage +~~~~~~~~~~ + +**type**: ``string`` **default**: ``This collection should contain {{ limit }} elements or more.`` + +The message that will be shown if the underlying collection elements count +is less than the `min`_ option. You can use the following parameters in this message: -+------------------+------------------------------------------------+ -| Parameter | Description | -+==================+================================================+ -| ``{{ count }}`` | The current collection size | -+------------------+------------------------------------------------+ -| ``{{ limit }}`` | The exact expected collection size | -+------------------+------------------------------------------------+ +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ count }}`` The current collection size +``{{ limit }}`` The lower limit +=============== ============================================================== .. include:: /reference/constraints/_payload-option.rst.inc diff --git a/reference/constraints/Country.rst b/reference/constraints/Country.rst index e8089671438..6da9c5bc397 100644 --- a/reference/constraints/Country.rst +++ b/reference/constraints/Country.rst @@ -3,17 +3,14 @@ Country Validates that a value is a valid `ISO 3166-1 alpha-2`_ country code. -+----------------+------------------------------------------------------------------------+ -| Applies to | :ref:`property or method ` | -+----------------+------------------------------------------------------------------------+ -| Options | - `groups`_ | -| | - `message`_ | -| | - `payload`_ | -+----------------+------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Country` | -+----------------+------------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\CountryValidator` | -+----------------+------------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `groups`_ + - `message`_ + - `payload`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\Country` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\CountryValidator` +========== =================================================================== Basic Usage ----------- @@ -90,11 +87,11 @@ This message is shown if the string is not a valid country code. You can use the following parameters in this message: -+------------------+------------------------------------------------+ -| Parameter | Description | -+==================+================================================+ -| ``{{ value }}`` | The current (invalid) country code | -+------------------+------------------------------------------------+ +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ value }}`` The current (invalid) country code +=============== ============================================================== .. include:: /reference/constraints/_payload-option.rst.inc diff --git a/reference/constraints/Currency.rst b/reference/constraints/Currency.rst index 1186806808d..021b336d9cb 100644 --- a/reference/constraints/Currency.rst +++ b/reference/constraints/Currency.rst @@ -3,17 +3,14 @@ Currency Validates that a value is a valid `3-letter ISO 4217`_ currency name. -+----------------+---------------------------------------------------------------------------+ -| Applies to | :ref:`property or method` | -+----------------+---------------------------------------------------------------------------+ -| Options | - `groups`_ | -| | - `message`_ | -| | - `payload`_ | -+----------------+---------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Currency` | -+----------------+---------------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\CurrencyValidator` | -+----------------+---------------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `groups`_ + - `message`_ + - `payload`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\Currency` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\CurrencyValidator` +========== =================================================================== Basic Usage ----------- @@ -93,11 +90,11 @@ This is the message that will be shown if the value is not a valid currency. You can use the following parameters in this message: -+------------------+------------------------------------------------+ -| Parameter | Description | -+==================+================================================+ -| ``{{ value }}`` | The current (invalid) value | -+------------------+------------------------------------------------+ +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ value }}`` The current (invalid) value +=============== ============================================================== .. include:: /reference/constraints/_payload-option.rst.inc diff --git a/reference/constraints/Date.rst b/reference/constraints/Date.rst index c9c9c4941d1..00c5d2567fc 100644 --- a/reference/constraints/Date.rst +++ b/reference/constraints/Date.rst @@ -4,17 +4,14 @@ Date Validates that a value is a valid date, meaning a string (or an object that can be cast into a string) that follows a valid ``YYYY-MM-DD`` format. -+----------------+--------------------------------------------------------------------+ -| Applies to | :ref:`property or method ` | -+----------------+--------------------------------------------------------------------+ -| Options | - `groups`_ | -| | - `message`_ | -| | - `payload`_ | -+----------------+--------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Date` | -+----------------+--------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\DateValidator` | -+----------------+--------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `groups`_ + - `message`_ + - `payload`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\Date` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\DateValidator` +========== =================================================================== Basic Usage ----------- @@ -97,10 +94,10 @@ This message is shown if the underlying data is not a valid date. You can use the following parameters in this message: -+------------------+------------------------------------------------+ -| Parameter | Description | -+==================+================================================+ -| ``{{ value }}`` | The current (invalid) value | -+------------------+------------------------------------------------+ +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ value }}`` The current (invalid) value +=============== ============================================================== .. include:: /reference/constraints/_payload-option.rst.inc diff --git a/reference/constraints/DateTime.rst b/reference/constraints/DateTime.rst index fc26179b8ab..e75a5800dec 100644 --- a/reference/constraints/DateTime.rst +++ b/reference/constraints/DateTime.rst @@ -4,18 +4,15 @@ DateTime Validates that a value is a valid "datetime", meaning a string (or an object that can be cast into a string) that follows a specific format. -+----------------+------------------------------------------------------------------------+ -| Applies to | :ref:`property or method ` | -+----------------+------------------------------------------------------------------------+ -| Options | - `format`_ | -| | - `groups`_ | -| | - `message`_ | -| | - `payload`_ | -+----------------+------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\DateTime` | -+----------------+------------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\DateTimeValidator` | -+----------------+------------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `format`_ + - `groups`_ + - `message`_ + - `payload`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\DateTime` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\DateTimeValidator` +========== =================================================================== Basic Usage ----------- @@ -106,10 +103,10 @@ This message is shown if the underlying data is not a valid datetime. You can use the following parameters in this message: -+------------------+------------------------------------------------+ -| Parameter | Description | -+==================+================================================+ -| ``{{ value }}`` | The current (invalid) value | -+------------------+------------------------------------------------+ +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ value }}`` The current (invalid) value +=============== ============================================================== .. include:: /reference/constraints/_payload-option.rst.inc diff --git a/reference/constraints/DivisibleBy.rst b/reference/constraints/DivisibleBy.rst index b45902bd5be..c5cee2f6405 100644 --- a/reference/constraints/DivisibleBy.rst +++ b/reference/constraints/DivisibleBy.rst @@ -3,18 +3,16 @@ DivisibleBy Validates that a value is divisible by another value, defined in the options. -+----------------+---------------------------------------------------------------------------+ -| Applies to | :ref:`property or method` | -+----------------+---------------------------------------------------------------------------+ -| Options | - `value`_ | -| | - `message`_ | -| | - `payload`_ | -| | - `propertyPath`_ | -+----------------+---------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\DivisibleBy` | -+----------------+---------------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\DivisibleByValidator` | -+----------------+---------------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `groups`_ + - `message`_ + - `payload`_ + - `propertyPath`_ + - `value`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\DivisibleBy` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\DivisibleByValidator` +========== =================================================================== Basic Usage ----------- @@ -105,7 +103,7 @@ The following constraints ensure that: Options ------- -.. include:: /reference/constraints/_comparison-value-option.rst.inc +.. include:: /reference/constraints/_groups-option.rst.inc message ~~~~~~~ @@ -127,3 +125,5 @@ It defines the object property whose value is used to make the comparison. For example, if you want to compare the ``$value`` property of some object with regard to the ``$increments`` property of the same object, use ``propertyPath="increments"`` in the comparison constraint of ``$value``. + +.. include:: /reference/constraints/_comparison-value-option.rst.inc diff --git a/reference/constraints/Email.rst b/reference/constraints/Email.rst index 17b3375c5b6..e49724acfae 100644 --- a/reference/constraints/Email.rst +++ b/reference/constraints/Email.rst @@ -4,20 +4,17 @@ Email Validates that a value is a valid email address. The underlying value is cast to a string before being validated. -+----------------+---------------------------------------------------------------------+ -| Applies to | :ref:`property or method ` | -+----------------+---------------------------------------------------------------------+ -| Options | - `mode`_ | -| | - `message`_ | -| | - `checkMX`_ | -| | - `checkHost`_ | -| | - `payload`_ | -| | - `groups`_ | -+----------------+---------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Email` | -+----------------+---------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\EmailValidator` | -+----------------+---------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `checkHost`_ + - `checkMX`_ + - `groups`_ + - `message`_ + - `mode`_ + - `payload`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\Email` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\EmailValidator` +========== =================================================================== Basic Usage ----------- @@ -94,36 +91,37 @@ Basic Usage Options ------- -.. include:: /reference/constraints/_groups-option.rst.inc +checkHost +~~~~~~~~~ -mode -~~~~ +**type**: ``boolean`` **default**: ``false`` -**type**: ``string`` **default**: ``loose`` +.. versionadded:: 4.2 -This option is optional and defines the pattern the email address is validated against. -Valid values are: + This option was deprecated in Symfony 4.2. -* ``loose`` -* ``strict`` -* ``html5`` +If true, then the :phpfunction:`checkdnsrr` PHP function will be used to +check the validity of the MX *or* the A *or* the AAAA record of the host +of the given email. -loose -..... +checkMX +~~~~~~~ -A simple regular expression. Allows all values with an "@" symbol in, and a "." -in the second host part of the email address. +**type**: ``boolean`` **default**: ``false`` -strict -...... +.. versionadded:: 4.2 -Uses the `egulias/email-validator`_ library to perform an RFC compliant -validation. You will need to install that library to use this mode. + This option was deprecated in Symfony 4.2. -html5 -..... +If true, then the :phpfunction:`checkdnsrr` PHP function will be used to +check the validity of the MX record of the host of the given email. -This matches the pattern used for the `HTML5 email input element`_. +.. caution:: + + This option is not reliable because it depends on the network conditions + and some valid servers refuse to respond to those requests. + +.. include:: /reference/constraints/_groups-option.rst.inc message ~~~~~~~ @@ -134,41 +132,40 @@ This message is shown if the underlying data is not a valid email address. You can use the following parameters in this message: -+------------------+------------------------------------------------+ -| Parameter | Description | -+==================+================================================+ -| ``{{ value }}`` | The current (invalid) value | -+------------------+------------------------------------------------+ - -checkMX -~~~~~~~ - -**type**: ``boolean`` **default**: ``false`` +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ value }}`` The current (invalid) value +=============== ============================================================== -.. versionadded:: 4.2 +mode +~~~~ - This option was deprecated in Symfony 4.2. +**type**: ``string`` **default**: ``loose`` -If true, then the :phpfunction:`checkdnsrr` PHP function will be used to -check the validity of the MX record of the host of the given email. +This option is optional and defines the pattern the email address is validated against. +Valid values are: -.. caution:: +* ``loose`` +* ``strict`` +* ``html5`` - This option is not reliable because it depends on the network conditions - and some valid servers refuse to respond to those requests. +loose +..... -checkHost -~~~~~~~~~ +A simple regular expression. Allows all values with an "@" symbol in, and a "." +in the second host part of the email address. -**type**: ``boolean`` **default**: ``false`` +strict +...... -.. versionadded:: 4.2 +Uses the `egulias/email-validator`_ library to perform an RFC compliant +validation. You will need to install that library to use this mode. - This option was deprecated in Symfony 4.2. +html5 +..... -If true, then the :phpfunction:`checkdnsrr` PHP function will be used to -check the validity of the MX *or* the A *or* the AAAA record of the host -of the given email. +This matches the pattern used for the `HTML5 email input element`_. .. include:: /reference/constraints/_payload-option.rst.inc diff --git a/reference/constraints/EqualTo.rst b/reference/constraints/EqualTo.rst index 690eb33920c..46f070f87a6 100644 --- a/reference/constraints/EqualTo.rst +++ b/reference/constraints/EqualTo.rst @@ -10,19 +10,16 @@ To force that a value is *not* equal, see :doc:`/reference/constraints/NotEqualT equal. Use :doc:`/reference/constraints/IdenticalTo` to compare with ``===``. -+----------------+-----------------------------------------------------------------------+ -| Applies to | :ref:`property or method` | -+----------------+-----------------------------------------------------------------------+ -| Options | - `value`_ | -| | - `groups`_ | -| | - `message`_ | -| | - `payload`_ | -| | - `propertyPath`_ | -+----------------+-----------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\EqualTo` | -+----------------+-----------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\EqualToValidator` | -+----------------+-----------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `groups`_ + - `message`_ + - `payload`_ + - `propertyPath`_ + - `value`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\EqualTo` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\EqualToValidator` +========== =================================================================== Basic Usage ----------- @@ -110,8 +107,6 @@ and that the ``age`` is ``20``, you could do the following: Options ------- -.. include:: /reference/constraints/_comparison-value-option.rst.inc - .. include:: /reference/constraints/_groups-option.rst.inc message @@ -123,16 +118,16 @@ This is the message that will be shown if the value is not equal. You can use the following parameters in this message: -+-------------------------------+-----------------------------+ -| Parameter | Description | -+===============================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-------------------------------+-----------------------------+ -| ``{{ compared_value }}`` | The expected value | -+-------------------------------+-----------------------------+ -| ``{{ compared_value_type }}`` | The expected value type | -+-------------------------------+-----------------------------+ +============================= ================================================ +Parameter Description +============================= ================================================ +``{{ compared_value }}`` The expected value +``{{ compared_value_type }}`` The expected value type +``{{ value }}`` The current (invalid) value +============================= ================================================ .. include:: /reference/constraints/_payload-option.rst.inc .. include:: /reference/constraints/_comparison-propertypath-option.rst.inc + +.. include:: /reference/constraints/_comparison-value-option.rst.inc diff --git a/reference/constraints/Expression.rst b/reference/constraints/Expression.rst index 5e0f7c61ed9..a97d4986cc3 100644 --- a/reference/constraints/Expression.rst +++ b/reference/constraints/Expression.rst @@ -6,19 +6,17 @@ for more complex, dynamic validation. See `Basic Usage`_ for an example. See :doc:`/reference/constraints/Callback` for a different constraint that gives you similar flexibility. -+----------------+-----------------------------------------------------------------------------------------------+ -| Applies to | :ref:`class ` or :ref:`property/method ` | -+----------------+-----------------------------------------------------------------------------------------------+ -| Options | - :ref:`expression ` | -| | - `groups`_ | -| | - `message`_ | -| | - `payload`_ | -| | - `values`_ | -+----------------+-----------------------------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Expression` | -+----------------+-----------------------------------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\ExpressionValidator` | -+----------------+-----------------------------------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`class ` + or :ref:`property/method ` +Options - :ref:`expression ` + - `groups`_ + - `message`_ + - `payload`_ + - `values`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\Expression` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\ExpressionValidator` +========== =================================================================== Basic Usage ----------- @@ -258,11 +256,11 @@ The default message supplied when the expression evaluates to false. You can use the following parameters in this message: -+-----------------+-----------------------------+ -| Parameter | Description | -+=================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-----------------+-----------------------------+ +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ value }}`` The current (invalid) value +=============== ============================================================== .. include:: /reference/constraints/_payload-option.rst.inc diff --git a/reference/constraints/File.rst b/reference/constraints/File.rst index 437e90d8f1a..12dd589ecc2 100644 --- a/reference/constraints/File.rst +++ b/reference/constraints/File.rst @@ -16,32 +16,29 @@ form field. If the file you're validating is an image, try the :doc:`Image ` constraint. -+----------------+---------------------------------------------------------------------+ -| Applies to | :ref:`property or method ` | -+----------------+---------------------------------------------------------------------+ -| Options | - `maxSize`_ | -| | - `binaryFormat`_ | -| | - `mimeTypes`_ | -| | - `maxSizeMessage`_ | -| | - `mimeTypesMessage`_ | -| | - `disallowEmptyMessage`_ | -| | - `notFoundMessage`_ | -| | - `notReadableMessage`_ | -| | - `uploadIniSizeErrorMessage`_ | -| | - `uploadFormSizeErrorMessage`_ | -| | - `uploadPartialErrorMessage`_ | -| | - `uploadNoFileErrorMessage`_ | -| | - `uploadNoTmpDirErrorMessage`_ | -| | - `uploadCantWriteErrorMessage`_ | -| | - `uploadExtensionErrorMessage`_ | -| | - `uploadErrorMessage`_ | -| | - `payload`_ | -| | - `groups`_ | -+----------------+---------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\File` | -+----------------+---------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\FileValidator` | -+----------------+---------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `binaryFormat`_ + - `disallowEmptyMessage`_ + - `groups`_ + - `maxSize`_ + - `maxSizeMessage`_ + - `mimeTypes`_ + - `mimeTypesMessage`_ + - `notFoundMessage`_ + - `notReadableMessage`_ + - `payload`_ + - `uploadCantWriteErrorMessage`_ + - `uploadErrorMessage`_ + - `uploadExtensionErrorMessage`_ + - `uploadFormSizeErrorMessage`_ + - `uploadIniSizeErrorMessage`_ + - `uploadNoFileErrorMessage`_ + - `uploadNoTmpDirErrorMessage`_ + - `uploadPartialErrorMessage`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\File` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\FileValidator` +========== =================================================================== Basic Usage ----------- @@ -161,6 +158,38 @@ have been specified. Options ------- +binaryFormat +~~~~~~~~~~~~ + +**type**: ``boolean`` **default**: ``null`` + +When ``true``, the sizes will be displayed in messages with binary-prefixed +units (KiB, MiB). When ``false``, the sizes will be displayed with SI-prefixed +units (kB, MB). When ``null``, then the binaryFormat will be guessed from +the value defined in the ``maxSize`` option. + +For more information about the difference between binary and SI prefixes, +see `Wikipedia: Binary prefix`_. + +disallowEmptyMessage +~~~~~~~~~~~~~~~~~~~~ + +**type**: ``string`` **default**: ``An empty file is not allowed.`` + +This constraint checks if the uploaded file is empty (i.e. 0 bytes). If it is, +this message is displayed. + +You can use the following parameters in this message: + +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ file }}`` Absolute file path +``{{ name }}`` Base file name +=============== ============================================================== + +.. include:: /reference/constraints/_groups-option.rst.inc + maxSize ~~~~~~~ @@ -170,35 +199,37 @@ If set, the size of the underlying file must be below this file size in order to be valid. The size of the file can be given in one of the following formats: -+--------+-----------+-----------------+------+ -| Suffix | Unit Name | value | e.g. | -+========+===========+=================+======+ -| | byte | 1 byte | 4096 | -+--------+-----------+-----------------+------+ -| k | kilobyte | 1,000 bytes | 200k | -+--------+-----------+-----------------+------+ -| M | megabyte | 1,000,000 bytes | 2M | -+--------+-----------+-----------------+------+ -| Ki | kibibyte | 1,024 bytes | 32Ki | -+--------+-----------+-----------------+------+ -| Mi | mebibyte | 1,048,576 bytes | 8Mi | -+--------+-----------+-----------------+------+ +====== ========= =============== ======== +Suffix Unit Name Value Example +====== ========= =============== ======== +(none) byte 1 byte ``4096`` +``k`` kilobyte 1,000 bytes ``200k`` +``M`` megabyte 1,000,000 bytes ``2M`` +``Ki`` kibibyte 1,024 bytes ``32Ki`` +``Mi`` mebibyte 1,048,576 bytes ``8Mi`` +====== ========= =============== ======== For more information about the difference between binary and SI prefixes, see `Wikipedia: Binary prefix`_. -binaryFormat -~~~~~~~~~~~~ +maxSizeMessage +~~~~~~~~~~~~~~ -**type**: ``boolean`` **default**: ``null`` +**type**: ``string`` **default**: ``The file is too large ({{ size }} {{ suffix }}). Allowed maximum size is {{ limit }} {{ suffix }}.`` -When ``true``, the sizes will be displayed in messages with binary-prefixed -units (KiB, MiB). When ``false``, the sizes will be displayed with SI-prefixed -units (kB, MB). When ``null``, then the binaryFormat will be guessed from -the value defined in the ``maxSize`` option. +The message displayed if the file is larger than the `maxSize`_ option. -For more information about the difference between binary and SI prefixes, -see `Wikipedia: Binary prefix`_. +You can use the following parameters in this message: + +================ ============================================================= +Parameter Description +================ ============================================================= +``{{ file }}`` Absolute file path +``{{ limit }}`` Maximum file size allowed +``{{ name }}`` Base file name +``{{ size }}`` File size of the given file +``{{ suffix }}`` Suffix for the used file size unit (see above) +================ ============================================================= mimeTypes ~~~~~~~~~ @@ -211,29 +242,6 @@ of given mime types (if an array). You can find a list of existing mime types on the `IANA website`_. -maxSizeMessage -~~~~~~~~~~~~~~ - -**type**: ``string`` **default**: ``The file is too large ({{ size }} {{ suffix }}). Allowed maximum size is {{ limit }} {{ suffix }}.`` - -The message displayed if the file is larger than the `maxSize`_ option. - -You can use the following parameters in this message: - -+------------------+------------------------------------------------+ -| Parameter | Description | -+==================+================================================+ -| ``{{ size }}`` | File size of the given file | -+------------------+------------------------------------------------+ -| ``{{ limit }}`` | Maximum file size allowed | -+------------------+------------------------------------------------+ -| ``{{ suffix }}`` | Suffix for the used file size unit (see above) | -+------------------+------------------------------------------------+ -| ``{{ file }}`` | Absolute file path | -+------------------+------------------------------------------------+ -| ``{{ name }}`` | Base file name | -+------------------+------------------------------------------------+ - mimeTypesMessage ~~~~~~~~~~~~~~~~ @@ -244,35 +252,14 @@ per the `mimeTypes`_ option. You can use the following parameters in this message: -+-----------------+----------------------------------------+ -| Parameter | Description | -+=================+========================================+ -| ``{{ type }}`` | The MIME type of the given file | -+-----------------+----------------------------------------+ -| ``{{ types }}`` | The list of allowed MIME types | -+-----------------+----------------------------------------+ -| ``{{ file }}`` | Absolute file path | -+-----------------+----------------------------------------+ -| ``{{ name }}`` | Base file name | -+-----------------+----------------------------------------+ - -disallowEmptyMessage -~~~~~~~~~~~~~~~~~~~~ - -**type**: ``string`` **default**: ``An empty file is not allowed.`` - -This constraint checks if the uploaded file is empty (i.e. 0 bytes). If it is, -this message is displayed. - -You can use the following parameters in this message: - -+----------------+--------------------+ -| Parameter | Description | -+================+====================+ -| ``{{ file }}`` | Absolute file path | -+----------------+--------------------+ -| ``{{ name }}`` | Base file name | -+----------------+--------------------+ +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ file }}`` Absolute file path +``{{ name }}`` Base file name +``{{ type }}`` The MIME type of the given file +``{{ types }}`` The list of allowed MIME types +=============== ============================================================== notFoundMessage ~~~~~~~~~~~~~~~ @@ -285,11 +272,11 @@ cannot be constructed with an invalid file path. You can use the following parameters in this message: -+----------------+--------------------+ -| Parameter | Description | -+================+====================+ -| ``{{ file }}`` | Absolute file path | -+----------------+--------------------+ +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ file }}`` Absolute file path +=============== ============================================================== notReadableMessage ~~~~~~~~~~~~~~~~~~ @@ -301,29 +288,43 @@ fails when passed the path to the file. You can use the following parameters in this message: -+----------------+--------------------+ -| Parameter | Description | -+================+====================+ -| ``{{ file }}`` | Absolute file path | -+----------------+--------------------+ +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ file }}`` Absolute file path +=============== ============================================================== -uploadIniSizeErrorMessage -~~~~~~~~~~~~~~~~~~~~~~~~~ +.. include:: /reference/constraints/_payload-option.rst.inc -**type**: ``string`` **default**: ``The file is too large. Allowed maximum size is {{ limit }} {{ suffix }}.`` +uploadCantWriteErrorMessage +~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The message that is displayed if the uploaded file is larger than the ``upload_max_filesize`` -``php.ini`` setting. +**type**: ``string`` **default**: ``Cannot write temporary file to disk.`` -You can use the following parameters in this message: +The message that is displayed if the uploaded file can't be stored in the +temporary folder. + +This message has no parameters. + +uploadErrorMessage +~~~~~~~~~~~~~~~~~~ + +**type**: ``string`` **default**: ``The file could not be uploaded.`` -+------------------+------------------------------------------------+ -| Parameter | Description | -+==================+================================================+ -| ``{{ limit }}`` | Maximum file size allowed | -+------------------+------------------------------------------------+ -| ``{{ suffix }}`` | Suffix for the used file size unit (see above) | -+------------------+------------------------------------------------+ +The message that is displayed if the uploaded file could not be uploaded +for some unknown reason. + +This message has no parameters. + +uploadExtensionErrorMessage +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +**type**: ``string`` **default**: ``A PHP extension caused the upload to fail.`` + +The message that is displayed if a PHP extension caused the file upload to +fail. + +This message has no parameters. uploadFormSizeErrorMessage ~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -335,14 +336,22 @@ by the HTML file input field. This message has no parameters. -uploadPartialErrorMessage +uploadIniSizeErrorMessage ~~~~~~~~~~~~~~~~~~~~~~~~~ -**type**: ``string`` **default**: ``The file was only partially uploaded.`` +**type**: ``string`` **default**: ``The file is too large. Allowed maximum size is {{ limit }} {{ suffix }}.`` -The message that is displayed if the uploaded file is only partially uploaded. +The message that is displayed if the uploaded file is larger than the ``upload_max_filesize`` +``php.ini`` setting. -This message has no parameters. +You can use the following parameters in this message: + +================ ============================================================= +Parameter Description +================ ============================================================= +``{{ limit }}`` Maximum file size allowed +``{{ suffix }}`` Suffix for the used file size unit (see above) +================ ============================================================= uploadNoFileErrorMessage ~~~~~~~~~~~~~~~~~~~~~~~~ @@ -363,39 +372,14 @@ missing. This message has no parameters. -uploadCantWriteErrorMessage -~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -**type**: ``string`` **default**: ``Cannot write temporary file to disk.`` - -The message that is displayed if the uploaded file can't be stored in the -temporary folder. - -This message has no parameters. - -uploadExtensionErrorMessage -~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -**type**: ``string`` **default**: ``A PHP extension caused the upload to fail.`` - -The message that is displayed if a PHP extension caused the file upload to -fail. - -This message has no parameters. - -uploadErrorMessage -~~~~~~~~~~~~~~~~~~ +uploadPartialErrorMessage +~~~~~~~~~~~~~~~~~~~~~~~~~ -**type**: ``string`` **default**: ``The file could not be uploaded.`` +**type**: ``string`` **default**: ``The file was only partially uploaded.`` -The message that is displayed if the uploaded file could not be uploaded -for some unknown reason. +The message that is displayed if the uploaded file is only partially uploaded. This message has no parameters. -.. include:: /reference/constraints/_payload-option.rst.inc - -.. include:: /reference/constraints/_groups-option.rst.inc - .. _`IANA website`: http://www.iana.org/assignments/media-types/index.html .. _`Wikipedia: Binary prefix`: http://en.wikipedia.org/wiki/Binary_prefix diff --git a/reference/constraints/GreaterThan.rst b/reference/constraints/GreaterThan.rst index 656c86a49d8..61d83027a72 100644 --- a/reference/constraints/GreaterThan.rst +++ b/reference/constraints/GreaterThan.rst @@ -6,19 +6,16 @@ force that a value is greater than or equal to another value, see :doc:`/reference/constraints/GreaterThanOrEqual`. To force a value is less than another value, see :doc:`/reference/constraints/LessThan`. -+----------------+---------------------------------------------------------------------------+ -| Applies to | :ref:`property or method` | -+----------------+---------------------------------------------------------------------------+ -| Options | - `value`_ | -| | - `groups`_ | -| | - `message`_ | -| | - `payload`_ | -| | - `propertyPath`_ | -+----------------+---------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\GreaterThan` | -+----------------+---------------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\GreaterThanValidator` | -+----------------+---------------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `groups`_ + - `message`_ + - `payload`_ + - `propertyPath`_ + - `value`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\GreaterThan` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\GreaterThanValidator` +========== =================================================================== Basic Usage ----------- @@ -291,8 +288,6 @@ current time: Options ------- -.. include:: /reference/constraints/_comparison-value-option.rst.inc - .. include:: /reference/constraints/_groups-option.rst.inc message @@ -305,18 +300,18 @@ comparison value. You can use the following parameters in this message: -+-------------------------------+-----------------------------+ -| Parameter | Description | -+===============================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-------------------------------+-----------------------------+ -| ``{{ compared_value }}`` | The lower limit | -+-------------------------------+-----------------------------+ -| ``{{ compared_value_type }}`` | The expected value type | -+-------------------------------+-----------------------------+ +============================= ================================================ +Parameter Description +============================= ================================================ +``{{ compared_value }}`` The lower limit +``{{ compared_value_type }}`` The expected value type +``{{ value }}`` The current (invalid) value +============================= ================================================ .. include:: /reference/constraints/_payload-option.rst.inc .. include:: /reference/constraints/_comparison-propertypath-option.rst.inc +.. include:: /reference/constraints/_comparison-value-option.rst.inc + .. _`accepted by the DateTime constructor`: https://php.net/manual/en/datetime.formats.php diff --git a/reference/constraints/GreaterThanOrEqual.rst b/reference/constraints/GreaterThanOrEqual.rst index 3e80e49a9df..1a4cd4aa5cd 100644 --- a/reference/constraints/GreaterThanOrEqual.rst +++ b/reference/constraints/GreaterThanOrEqual.rst @@ -5,19 +5,16 @@ Validates that a value is greater than or equal to another value, defined in the options. To force that a value is greater than another value, see :doc:`/reference/constraints/GreaterThan`. -+----------------+----------------------------------------------------------------------------------+ -| Applies to | :ref:`property or method` | -+----------------+----------------------------------------------------------------------------------+ -| Options | - `value`_ | -| | - `groups`_ | -| | - `message`_ | -| | - `payload`_ | -| | - `propertyPath`_ | -+----------------+----------------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\GreaterThanOrEqual` | -+----------------+----------------------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\GreaterThanOrEqualValidator` | -+----------------+----------------------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `groups`_ + - `message`_ + - `payload`_ + - `propertyPath`_ + - `value`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\GreaterThanOrEqual` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\GreaterThanOrEqualValidator` +========== =================================================================== Basic Usage ----------- @@ -289,8 +286,6 @@ current time: Options ------- -.. include:: /reference/constraints/_comparison-value-option.rst.inc - .. include:: /reference/constraints/_groups-option.rst.inc message @@ -303,18 +298,18 @@ to the comparison value. You can use the following parameters in this message: -+-------------------------------+-----------------------------+ -| Parameter | Description | -+===============================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-------------------------------+-----------------------------+ -| ``{{ compared_value }}`` | The lower limit | -+-------------------------------+-----------------------------+ -| ``{{ compared_value_type }}`` | The expected value type | -+-------------------------------+-----------------------------+ +============================= ================================================ +Parameter Description +============================= ================================================ +``{{ compared_value }}`` The lower limit +``{{ compared_value_type }}`` The expected value type +``{{ value }}`` The current (invalid) value +============================= ================================================ .. include:: /reference/constraints/_payload-option.rst.inc .. include:: /reference/constraints/_comparison-propertypath-option.rst.inc +.. include:: /reference/constraints/_comparison-value-option.rst.inc + .. _`accepted by the DateTime constructor`: https://php.net/manual/en/datetime.formats.php diff --git a/reference/constraints/Iban.rst b/reference/constraints/Iban.rst index 0029a302d52..a43eba86c3e 100644 --- a/reference/constraints/Iban.rst +++ b/reference/constraints/Iban.rst @@ -6,17 +6,14 @@ format of an `International Bank Account Number (IBAN)`_. IBAN is an internationally agreed means of identifying bank accounts across national borders with a reduced risk of propagating transcription errors. -+----------------+-----------------------------------------------------------------------+ -| Applies to | :ref:`property or method` | -+----------------+-----------------------------------------------------------------------+ -| Options | - `groups`_ | -| | - `message`_ | -| | - `payload`_ | -+----------------+-----------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Iban` | -+----------------+-----------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\IbanValidator` | -+----------------+-----------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `groups`_ + - `message`_ + - `payload`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\Iban` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\IbanValidator` +========== =================================================================== Basic Usage ----------- @@ -107,11 +104,11 @@ The default message supplied when the value does not pass the Iban check. You can use the following parameters in this message: -+-----------------+-----------------------------+ -| Parameter | Description | -+=================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-----------------+-----------------------------+ +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ value }}`` The current (invalid) value +=============== ============================================================== .. include:: /reference/constraints/_payload-option.rst.inc diff --git a/reference/constraints/IdenticalTo.rst b/reference/constraints/IdenticalTo.rst index ab12ddbfd11..6ccb15a8eda 100644 --- a/reference/constraints/IdenticalTo.rst +++ b/reference/constraints/IdenticalTo.rst @@ -11,19 +11,16 @@ To force that a value is *not* identical, see considered equal. Use :doc:`/reference/constraints/EqualTo` to compare with ``==``. -+----------------+--------------------------------------------------------------------------+ -| Applies to | :ref:`property or method` | -+----------------+--------------------------------------------------------------------------+ -| Options | - `value`_ | -| | - `groups`_ | -| | - `message`_ | -| | - `payload`_ | -| | - `propertyPath`_ | -+----------------+--------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\IdenticalTo` | -+----------------+--------------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\IdenticalToValidator`| -+----------------+--------------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `groups`_ + - `message`_ + - `payload`_ + - `propertyPath`_ + - `value`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\IdenticalTo` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\IdenticalToValidator` +========== =================================================================== Basic Usage ----------- @@ -113,8 +110,6 @@ The following constraints ensure that: Options ------- -.. include:: /reference/constraints/_comparison-value-option.rst.inc - .. include:: /reference/constraints/_groups-option.rst.inc message @@ -126,16 +121,16 @@ This is the message that will be shown if the value is not identical. You can use the following parameters in this message: -+-------------------------------+-----------------------------+ -| Parameter | Description | -+===============================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-------------------------------+-----------------------------+ -| ``{{ compared_value }}`` | The expected value | -+-------------------------------+-----------------------------+ -| ``{{ compared_value_type }}`` | The expected value type | -+-------------------------------+-----------------------------+ +============================= ================================================ +Parameter Description +============================= ================================================ +``{{ compared_value }}`` The expected value +``{{ compared_value_type }}`` The expected value type +``{{ value }}`` The current (invalid) value +============================= ================================================ .. include:: /reference/constraints/_payload-option.rst.inc .. include:: /reference/constraints/_comparison-propertypath-option.rst.inc + +.. include:: /reference/constraints/_comparison-value-option.rst.inc diff --git a/reference/constraints/Image.rst b/reference/constraints/Image.rst index 63a14431f4c..fd51b7d8d7f 100644 --- a/reference/constraints/Image.rst +++ b/reference/constraints/Image.rst @@ -11,39 +11,40 @@ of the image. See the :doc:`File ` constraint for the bulk of the documentation on this constraint. -+----------------+-----------------------------------------------------------------------+ -| Applies to | :ref:`property or method ` | -+----------------+-----------------------------------------------------------------------+ -| Options | - `mimeTypes`_ | -| | - `minWidth`_ | -| | - `maxWidth`_ | -| | - `maxHeight`_ | -| | - `minHeight`_ | -| | - `maxRatio`_ | -| | - `minRatio`_ | -| | - `allowSquare`_ | -| | - `allowLandscape`_ | -| | - `allowPortrait`_ | -| | - `detectCorrupted`_ | -| | - `mimeTypesMessage`_ | -| | - `sizeNotDetectedMessage`_ | -| | - `maxWidthMessage`_ | -| | - `minWidthMessage`_ | -| | - `maxHeightMessage`_ | -| | - `minHeightMessage`_ | -| | - `maxRatioMessage`_ | -| | - `minRatioMessage`_ | -| | - `allowSquareMessage`_ | -| | - `allowLandscapeMessage`_ | -| | - `allowPortraitMessage`_ | -| | - `corruptedMessage`_ | -| | - See :doc:`File ` for inherited options | -| | - `groups`_ | -+----------------+-----------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Image` | -+----------------+-----------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\ImageValidator` | -+----------------+-----------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `allowLandscape`_ + - `allowLandscapeMessage`_ + - `allowPortrait`_ + - `allowPortraitMessage`_ + - `allowSquare`_ + - `allowSquareMessage`_ + - `corruptedMessage`_ + - `detectCorrupted`_ + - `groups`_ + - `maxHeight`_ + - `maxHeightMessage`_ + - `maxPixels`_ + - `maxPixelsMessage`_ + - `maxRatio`_ + - `maxRatioMessage`_ + - `maxWidth`_ + - `maxWidthMessage`_ + - `mimeTypes`_ + - `mimeTypesMessage`_ + - `minHeight`_ + - `minHeightMessage`_ + - `minPixels`_ + - `minPixelsMessage`_ + - `minRatio`_ + - `minRatioMessage`_ + - `minWidth`_ + - `minWidthMessage`_ + - `sizeNotDetectedMessage`_ + - See :doc:`File ` for inherited options +Class :class:`Symfony\\Component\\Validator\\Constraints\\Image` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\ImageValidator` +========== =================================================================== Basic Usage ----------- @@ -231,41 +232,100 @@ This constraint shares all of its options with the :doc:`File ` | -+----------------+---------------------------------------------------------------------+ -| Options | - `version`_ | -| | - `groups`_ | -| | - `message`_ | -| | - `payload`_ | -+----------------+---------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Ip` | -+----------------+---------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\IpValidator` | -+----------------+---------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `groups`_ + - `message`_ + - `payload`_ + - `version`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\Ip` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\IpValidator` +========== =================================================================== Basic Usage ----------- @@ -82,6 +79,25 @@ Basic Usage Options ------- +.. include:: /reference/constraints/_groups-option.rst.inc + +message +~~~~~~~ + +**type**: ``string`` **default**: ``This is not a valid IP address.`` + +This message is shown if the string is not a valid IP address. + +You can use the following parameters in this message: + +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ value }}`` The current (invalid) value +=============== ============================================================== + +.. include:: /reference/constraints/_payload-option.rst.inc + version ~~~~~~~ @@ -125,22 +141,3 @@ of a variety of different values: Validates for IPv6 but without private and reserved ranges ``all_public`` Validates for all IP formats but without private and reserved ranges - -.. include:: /reference/constraints/_groups-option.rst.inc - -message -~~~~~~~ - -**type**: ``string`` **default**: ``This is not a valid IP address.`` - -This message is shown if the string is not a valid IP address. - -You can use the following parameters in this message: - -+-----------------+-----------------------------+ -| Parameter | Description | -+=================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-----------------+-----------------------------+ - -.. include:: /reference/constraints/_payload-option.rst.inc diff --git a/reference/constraints/IsFalse.rst b/reference/constraints/IsFalse.rst index 67fa3074e37..d996991dc85 100644 --- a/reference/constraints/IsFalse.rst +++ b/reference/constraints/IsFalse.rst @@ -7,17 +7,14 @@ string "``0``". Also see :doc:`IsTrue `. -+----------------+-----------------------------------------------------------------------+ -| Applies to | :ref:`property or method ` | -+----------------+-----------------------------------------------------------------------+ -| Options | - `groups`_ | -| | - `message`_ | -| | - `payload`_ | -+----------------+-----------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\IsFalse` | -+----------------+-----------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\IsFalseValidator` | -+----------------+-----------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `groups`_ + - `message`_ + - `payload`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\IsFalse` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\IsFalseValidator` +========== =================================================================== Basic Usage ----------- @@ -117,10 +114,10 @@ This message is shown if the underlying data is not false. You can use the following parameters in this message: -+-----------------+-----------------------------+ -| Parameter | Description | -+=================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-----------------+-----------------------------+ +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ value }}`` The current (invalid) value +=============== ============================================================== .. include:: /reference/constraints/_payload-option.rst.inc diff --git a/reference/constraints/IsNull.rst b/reference/constraints/IsNull.rst index 1f274f76215..b66c8328fe7 100644 --- a/reference/constraints/IsNull.rst +++ b/reference/constraints/IsNull.rst @@ -7,17 +7,14 @@ constraint. To ensure that a property is not null, see :doc:`/reference/constrai Also see :doc:`NotNull `. -+----------------+-----------------------------------------------------------------------+ -| Applies to | :ref:`property or method ` | -+----------------+-----------------------------------------------------------------------+ -| Options | - `groups`_ | -| | - `message`_ | -| | - `payload`_ | -+----------------+-----------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\IsNull` | -+----------------+-----------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\IsNullValidator` | -+----------------+-----------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `groups`_ + - `message`_ + - `payload`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\IsNull` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\IsNullValidator` +========== =================================================================== Basic Usage ----------- @@ -95,10 +92,10 @@ This is the message that will be shown if the value is not ``null``. You can use the following parameters in this message: -+-----------------+-----------------------------+ -| Parameter | Description | -+=================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-----------------+-----------------------------+ +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ value }}`` The current (invalid) value +=============== ============================================================== .. include:: /reference/constraints/_payload-option.rst.inc diff --git a/reference/constraints/IsTrue.rst b/reference/constraints/IsTrue.rst index b03750b1db6..9bf65c8c774 100644 --- a/reference/constraints/IsTrue.rst +++ b/reference/constraints/IsTrue.rst @@ -7,17 +7,14 @@ string "``1``". Also see :doc:`IsFalse `. -+----------------+---------------------------------------------------------------------+ -| Applies to | :ref:`property or method ` | -+----------------+---------------------------------------------------------------------+ -| Options | - `groups`_ | -| | - `message`_ | -| | - `payload`_ | -+----------------+---------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\IsTrue` | -+----------------+---------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\IsTrueValidator`| -+----------------+---------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `groups`_ + - `message`_ + - `payload`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\IsTrue` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\IsTrueValidator` +========== =================================================================== Basic Usage ----------- @@ -131,10 +128,10 @@ This message is shown if the underlying data is not true. You can use the following parameters in this message: -+-----------------+-----------------------------+ -| Parameter | Description | -+=================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-----------------+-----------------------------+ +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ value }}`` The current (invalid) value +=============== ============================================================== .. include:: /reference/constraints/_payload-option.rst.inc diff --git a/reference/constraints/Isbn.rst b/reference/constraints/Isbn.rst index faf91960646..9a6f7f7f840 100644 --- a/reference/constraints/Isbn.rst +++ b/reference/constraints/Isbn.rst @@ -4,21 +4,18 @@ Isbn This constraint validates that an `International Standard Book Number (ISBN)`_ is either a valid ISBN-10 or a valid ISBN-13. -+----------------+----------------------------------------------------------------------+ -| Applies to | :ref:`property or method` | -+----------------+----------------------------------------------------------------------+ -| Options | - `type`_ | -| | - `groups`_ | -| | - `message`_ | -| | - `isbn10Message`_ | -| | - `isbn13Message`_ | -| | - `bothIsbnMessage`_ | -| | - `payload`_ | -+----------------+----------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Isbn` | -+----------------+----------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\IsbnValidator` | -+----------------+----------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `bothIsbnMessage`_ + - `groups`_ + - `isbn10Message`_ + - `isbn13Message`_ + - `message`_ + - `payload`_ + - `type`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\Isbn` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\IsbnValidator` +========== =================================================================== Basic Usage ----------- @@ -100,31 +97,23 @@ on an object that will contain an ISBN. Available Options ----------------- -type -~~~~ - -**type**: ``string`` **default**: ``null`` - -The type of ISBN to validate against. Valid values are ``isbn10``, ``isbn13`` -and ``null`` to accept any kind of ISBN. - -.. include:: /reference/constraints/_groups-option.rst.inc - -message -~~~~~~~ +bothIsbnMessage +~~~~~~~~~~~~~~~ -**type**: ``string`` **default**: ``null`` +**type**: ``string`` **default**: ``This value is neither a valid ISBN-10 nor a valid ISBN-13.`` -The message that will be shown if the value is not valid. If not ``null``, -this message has priority over all the other messages. +The message that will be shown if the `type`_ option is ``null`` and the given +value does not pass any of the ISBN checks. You can use the following parameters in this message: -+-----------------+-----------------------------+ -| Parameter | Description | -+=================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-----------------+-----------------------------+ +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ value }}`` The current (invalid) value +=============== ============================================================== + +.. include:: /reference/constraints/_groups-option.rst.inc isbn10Message ~~~~~~~~~~~~~ @@ -136,11 +125,11 @@ value does not pass the ISBN-10 check. You can use the following parameters in this message: -+-----------------+-----------------------------+ -| Parameter | Description | -+=================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-----------------+-----------------------------+ +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ value }}`` The current (invalid) value +=============== ============================================================== isbn13Message ~~~~~~~~~~~~~ @@ -152,28 +141,36 @@ value does not pass the ISBN-13 check. You can use the following parameters in this message: -+-----------------+-----------------------------+ -| Parameter | Description | -+=================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-----------------+-----------------------------+ +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ value }}`` The current (invalid) value +=============== ============================================================== -bothIsbnMessage -~~~~~~~~~~~~~~~ +message +~~~~~~~ -**type**: ``string`` **default**: ``This value is neither a valid ISBN-10 nor a valid ISBN-13.`` +**type**: ``string`` **default**: ``null`` -The message that will be shown if the `type`_ option is ``null`` and the given -value does not pass any of the ISBN checks. +The message that will be shown if the value is not valid. If not ``null``, +this message has priority over all the other messages. You can use the following parameters in this message: -+-----------------+-----------------------------+ -| Parameter | Description | -+=================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-----------------+-----------------------------+ +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ value }}`` The current (invalid) value +=============== ============================================================== .. include:: /reference/constraints/_payload-option.rst.inc +type +~~~~ + +**type**: ``string`` **default**: ``null`` + +The type of ISBN to validate against. Valid values are ``isbn10``, ``isbn13`` +and ``null`` to accept any kind of ISBN. + .. _`International Standard Book Number (ISBN)`: https://en.wikipedia.org/wiki/Isbn diff --git a/reference/constraints/Issn.rst b/reference/constraints/Issn.rst index 21afa60ae42..0b4dfe932a1 100644 --- a/reference/constraints/Issn.rst +++ b/reference/constraints/Issn.rst @@ -4,19 +4,16 @@ Issn Validates that a value is a valid `International Standard Serial Number (ISSN)`_. -+----------------+-----------------------------------------------------------------------+ -| Applies to | :ref:`property or method` | -+----------------+-----------------------------------------------------------------------+ -| Options | - `groups`_ | -| | - `message`_ | -| | - `caseSensitive`_ | -| | - `requireHyphen`_ | -| | - `payload`_ | -+----------------+-----------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Issn` | -+----------------+-----------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\IssnValidator` | -+----------------+-----------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `caseSensitive`_ + - `groups`_ + - `message`_ + - `payload`_ + - `requireHyphen`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\Issn` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\IssnValidator` +========== =================================================================== Basic Usage ----------- @@ -82,6 +79,14 @@ Basic Usage Options ------- +caseSensitive +~~~~~~~~~~~~~ + +**type**: ``boolean`` default: ``false`` + +The validator will allow ISSN values to end with a lower case 'x' by default. +When switching this to ``true``, the validator requires an upper case 'X'. + .. include:: /reference/constraints/_groups-option.rst.inc message @@ -93,19 +98,13 @@ The message shown if the given value is not a valid ISSN. You can use the following parameters in this message: -+-----------------+-----------------------------+ -| Parameter | Description | -+=================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-----------------+-----------------------------+ - -caseSensitive -~~~~~~~~~~~~~ +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ value }}`` The current (invalid) value +=============== ============================================================== -**type**: ``boolean`` default: ``false`` - -The validator will allow ISSN values to end with a lower case 'x' by default. -When switching this to ``true``, the validator requires an upper case 'X'. +.. include:: /reference/constraints/_payload-option.rst.inc requireHyphen ~~~~~~~~~~~~~ @@ -115,6 +114,4 @@ requireHyphen The validator will allow non hyphenated ISSN values by default. When switching this to ``true``, the validator requires a hyphenated ISSN value. -.. include:: /reference/constraints/_payload-option.rst.inc - .. _`International Standard Serial Number (ISSN)`: https://en.wikipedia.org/wiki/Issn diff --git a/reference/constraints/Language.rst b/reference/constraints/Language.rst index f330ab427b0..74cf6c994cf 100644 --- a/reference/constraints/Language.rst +++ b/reference/constraints/Language.rst @@ -4,17 +4,14 @@ Language Validates that a value is a valid language *Unicode language identifier* (e.g. ``fr`` or ``zh-Hant``). -+----------------+------------------------------------------------------------------------+ -| Applies to | :ref:`property or method ` | -+----------------+------------------------------------------------------------------------+ -| Options | - `groups`_ | -| | - `message`_ | -| | - `payload`_ | -+----------------+------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Language` | -+----------------+------------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\LanguageValidator` | -+----------------+------------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `groups`_ + - `message`_ + - `payload`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\Language` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\LanguageValidator` +========== =================================================================== Basic Usage ----------- @@ -91,10 +88,10 @@ This message is shown if the string is not a valid language code. You can use the following parameters in this message: -+-----------------+-----------------------------+ -| Parameter | Description | -+=================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-----------------+-----------------------------+ +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ value }}`` The current (invalid) value +=============== ============================================================== .. include:: /reference/constraints/_payload-option.rst.inc diff --git a/reference/constraints/Length.rst b/reference/constraints/Length.rst index 8242a8de957..b37deb58433 100644 --- a/reference/constraints/Length.rst +++ b/reference/constraints/Length.rst @@ -9,23 +9,20 @@ Validates that a given string length is *between* some minimum and maximum value also add the :doc:`/reference/constraints/NotBlank` or :doc:`/reference/constraints/NotNull` constraints to validate against these. -+----------------+----------------------------------------------------------------------+ -| Applies to | :ref:`property or method ` | -+----------------+----------------------------------------------------------------------+ -| Options | - `min`_ | -| | - `max`_ | -| | - `charset`_ | -| | - `minMessage`_ | -| | - `maxMessage`_ | -| | - `exactMessage`_ | -| | - `charsetMessage`_ | -| | - `payload`_ | -| | - `groups`_ | -+----------------+----------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Length` | -+----------------+----------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\LengthValidator` | -+----------------+----------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `charset`_ + - `charsetMessage`_ + - `exactMessage`_ + - `groups`_ + - `max`_ + - `maxMessage`_ + - `min`_ + - `minMessage`_ + - `payload`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\Length` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\LengthValidator` +========== =================================================================== Basic Usage ----------- @@ -117,26 +114,6 @@ and "50", you might add the following: Options ------- -min -~~~ - -**type**: ``integer`` - -This required option is the "min" length value. Validation will fail if -the given value's length is **less** than this min value. - -It is important to notice that NULL values and empty strings are considered -valid no matter if the constraint required a minimum length. Validators -are triggered only if the value is not blank. - -max -~~~ - -**type**: ``integer`` - -This required option is the "max" length value. Validation will fail if -the given value's length is **greater** than this max value. - charset ~~~~~~~ @@ -147,23 +124,48 @@ The charset to be used when computing value's length. The the :phpfunction:`mb_strlen` PHP function is used if available. If neither are available, the :phpfunction:`strlen` PHP function is used. -minMessage -~~~~~~~~~~ +charsetMessage +~~~~~~~~~~~~~~ -**type**: ``string`` **default**: ``This value is too short. It should have {{ limit }} characters or more.`` +**type**: ``string`` **default**: ``This value does not match the expected {{ charset }} charset.`` -The message that will be shown if the underlying value's length is less -than the `min`_ option. +The message that will be shown if the value is not using the given `charset`_. + +You can use the following parameters in this message: + +================= ============================================================ +Parameter Description +================= ============================================================ +``{{ charset }}`` The expected charset +``{{ value }}`` The current (invalid) value +================= ============================================================ + +exactMessage +~~~~~~~~~~~~ + +**type**: ``string`` **default**: ``This value should have exactly {{ limit }} characters.`` + +The message that will be shown if min and max values are equal and the underlying +value's length is not exactly this value. You can use the following parameters in this message: -+-----------------+-----------------------------+ -| Parameter | Description | -+=================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-----------------+-----------------------------+ -| ``{{ limit }}`` | The expected minimum length | -+-----------------+-----------------------------+ +================= ============================================================ +Parameter Description +================= ============================================================ +``{{ limit }}`` The exact expected length +``{{ value }}`` The current (invalid) value +================= ============================================================ + +.. include:: /reference/constraints/_groups-option.rst.inc + +max +~~~ + +**type**: ``integer`` + +This required option is the "max" length value. Validation will fail if +the given value's length is **greater** than this max value. maxMessage ~~~~~~~~~~ @@ -175,49 +177,40 @@ than the `max`_ option. You can use the following parameters in this message: -+-----------------+-----------------------------+ -| Parameter | Description | -+=================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-----------------+-----------------------------+ -| ``{{ limit }}`` | The expected maximum length | -+-----------------+-----------------------------+ - -exactMessage -~~~~~~~~~~~~ +================= ============================================================ +Parameter Description +================= ============================================================ +``{{ limit }}`` The expected maximum length +``{{ value }}`` The current (invalid) value +================= ============================================================ -**type**: ``string`` **default**: ``This value should have exactly {{ limit }} characters.`` +min +~~~ -The message that will be shown if min and max values are equal and the underlying -value's length is not exactly this value. +**type**: ``integer`` -You can use the following parameters in this message: +This required option is the "min" length value. Validation will fail if +the given value's length is **less** than this min value. -+-----------------+-----------------------------+ -| Parameter | Description | -+=================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-----------------+-----------------------------+ -| ``{{ limit }}`` | The exact expected length | -+-----------------+-----------------------------+ +It is important to notice that NULL values and empty strings are considered +valid no matter if the constraint required a minimum length. Validators +are triggered only if the value is not blank. -charsetMessage -~~~~~~~~~~~~~~ +minMessage +~~~~~~~~~~ -**type**: ``string`` **default**: ``This value does not match the expected {{ charset }} charset.`` +**type**: ``string`` **default**: ``This value is too short. It should have {{ limit }} characters or more.`` -The message that will be shown if the value is not using the given `charset`_. +The message that will be shown if the underlying value's length is less +than the `min`_ option. You can use the following parameters in this message: -+-------------------+-----------------------------+ -| Parameter | Description | -+===================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-------------------+-----------------------------+ -| ``{{ charset }}`` | The expected charset | -+-------------------+-----------------------------+ +================= ============================================================ +Parameter Description +================= ============================================================ +``{{ limit }}`` The expected minimum length +``{{ value }}`` The current (invalid) value +================= ============================================================ .. include:: /reference/constraints/_payload-option.rst.inc - -.. include:: /reference/constraints/_groups-option.rst.inc diff --git a/reference/constraints/LessThan.rst b/reference/constraints/LessThan.rst index 5f93bc77029..28c44432824 100644 --- a/reference/constraints/LessThan.rst +++ b/reference/constraints/LessThan.rst @@ -6,19 +6,16 @@ force that a value is less than or equal to another value, see :doc:`/reference/constraints/LessThanOrEqual`. To force a value is greater than another value, see :doc:`/reference/constraints/GreaterThan`. -+----------------+------------------------------------------------------------------------+ -| Applies to | :ref:`property or method` | -+----------------+------------------------------------------------------------------------+ -| Options | - `value`_ | -| | - `groups`_ | -| | - `message`_ | -| | - `payload`_ | -| | - `propertyPath`_ | -+----------------+------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\LessThan` | -+----------------+------------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\LessThanValidator` | -+----------------+------------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `groups`_ + - `message`_ + - `payload`_ + - `propertyPath`_ + - `value`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\LessThan` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\LessThanValidator` +========== =================================================================== Basic Usage ----------- @@ -290,8 +287,6 @@ can check that a person must be at least 18 years old like this: Options ------- -.. include:: /reference/constraints/_comparison-value-option.rst.inc - .. include:: /reference/constraints/_groups-option.rst.inc message @@ -304,18 +299,18 @@ comparison value. You can use the following parameters in this message: -+-------------------------------+-----------------------------+ -| Parameter | Description | -+===============================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-------------------------------+-----------------------------+ -| ``{{ compared_value }}`` | The upper limit | -+-------------------------------+-----------------------------+ -| ``{{ compared_value_type }}`` | The expected value type | -+-------------------------------+-----------------------------+ +============================= ================================================ +Parameter Description +============================= ================================================ +``{{ compared_value }}`` The upper limit +``{{ compared_value_type }}`` The expected value type +``{{ value }}`` The current (invalid) value +============================= ================================================ .. include:: /reference/constraints/_payload-option.rst.inc .. include:: /reference/constraints/_comparison-propertypath-option.rst.inc +.. include:: /reference/constraints/_comparison-value-option.rst.inc + .. _`accepted by the DateTime constructor`: https://php.net/manual/en/datetime.formats.php diff --git a/reference/constraints/LessThanOrEqual.rst b/reference/constraints/LessThanOrEqual.rst index 4ac07c42b18..bcbdaa78889 100644 --- a/reference/constraints/LessThanOrEqual.rst +++ b/reference/constraints/LessThanOrEqual.rst @@ -5,19 +5,16 @@ Validates that a value is less than or equal to another value, defined in the options. To force that a value is less than another value, see :doc:`/reference/constraints/LessThan`. -+----------------+-------------------------------------------------------------------------------+ -| Applies to | :ref:`property or method` | -+----------------+-------------------------------------------------------------------------------+ -| Options | - `value`_ | -| | - `groups`_ | -| | - `message`_ | -| | - `payload`_ | -| | - `propertyPath`_ | -+----------------+-------------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\LessThanOrEqual` | -+----------------+-------------------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\LessThanOrEqualValidator` | -+----------------+-------------------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `groups`_ + - `message`_ + - `payload`_ + - `propertyPath`_ + - `value`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\LessThanOrEqual` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\LessThanOrEqualValidator` +========== =================================================================== Basic Usage ----------- @@ -288,8 +285,6 @@ can check that a person must be at least 18 years old like this: Options ------- -.. include:: /reference/constraints/_comparison-value-option.rst.inc - .. include:: /reference/constraints/_groups-option.rst.inc message @@ -302,18 +297,18 @@ to the comparison value. You can use the following parameters in this message: -+-------------------------------+-----------------------------+ -| Parameter | Description | -+===============================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-------------------------------+-----------------------------+ -| ``{{ compared_value }}`` | The upper limit | -+-------------------------------+-----------------------------+ -| ``{{ compared_value_type }}`` | The expected value type | -+-------------------------------+-----------------------------+ +============================= ================================================ +Parameter Description +============================= ================================================ +``{{ compared_value }}`` The upper limit +``{{ compared_value_type }}`` The expected value type +``{{ value }}`` The current (invalid) value +============================= ================================================ .. include:: /reference/constraints/_payload-option.rst.inc .. include:: /reference/constraints/_comparison-propertypath-option.rst.inc +.. include:: /reference/constraints/_comparison-value-option.rst.inc + .. _`accepted by the DateTime constructor`: https://php.net/manual/en/datetime.formats.php diff --git a/reference/constraints/Locale.rst b/reference/constraints/Locale.rst index e27b23a6d8d..8a7c88d0b5e 100644 --- a/reference/constraints/Locale.rst +++ b/reference/constraints/Locale.rst @@ -8,18 +8,15 @@ the two letter `ISO 639-1`_ *language* code (e.g. ``fr``), or the language code followed by an underscore (``_``) and the `ISO 3166-1 alpha-2`_ *country* code (e.g. ``fr_FR`` for French/France). -+----------------+------------------------------------------------------------------------+ -| Applies to | :ref:`property or method ` | -+----------------+------------------------------------------------------------------------+ -| Options | - `groups`_ | -| | - `message`_ | -| | - `payload`_ | -| | - `canonicalize`_ | -+----------------+------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Locale` | -+----------------+------------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\LocaleValidator` | -+----------------+------------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `canonicalize`_ + - `groups`_ + - `message`_ + - `payload`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\Locale` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\LocaleValidator` +========== =================================================================== Basic Usage ----------- @@ -90,6 +87,19 @@ Basic Usage Options ------- +canonicalize +~~~~~~~~~~~~ + +**type**: ``boolean`` **default**: ``false`` + +.. versionadded:: 4.1 + + Using this option with value ``false`` was deprecated in Symfony 4.1 and it + will throw an exception in Symfony 5.0. Use ``true`` instead. + +If ``true``, the :phpmethod:`Locale::canonicalize` method will be applied before checking +the validity of the given locale (e.g. ``FR-fr.utf8`` is transformed into ``fr_FR``). + .. include:: /reference/constraints/_groups-option.rst.inc message @@ -101,27 +111,14 @@ This message is shown if the string is not a valid locale. You can use the following parameters in this message: -+-----------------+-----------------------------+ -| Parameter | Description | -+=================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-----------------+-----------------------------+ +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ value }}`` The current (invalid) value +=============== ============================================================== .. include:: /reference/constraints/_payload-option.rst.inc -canonicalize -~~~~~~~~~~~~ - -**type**: ``boolean`` **default**: ``false`` - -.. versionadded:: 4.1 - - Using this option with value ``false`` was deprecated in Symfony 4.1 and it - will throw an exception in Symfony 5.0. Use ``true`` instead. - -If ``true``, the :phpmethod:`Locale::canonicalize` method will be applied before checking -the validity of the given locale (e.g. ``FR-fr.utf8`` is transformed into ``fr_FR``). - .. _`ICU format locale IDs`: http://userguide.icu-project.org/locale .. _`ISO 639-1`: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes .. _`ISO 3166-1 alpha-2`: https://en.wikipedia.org/wiki/ISO_3166-1#Current_codes diff --git a/reference/constraints/Luhn.rst b/reference/constraints/Luhn.rst index 071d5647e00..fa323b51115 100644 --- a/reference/constraints/Luhn.rst +++ b/reference/constraints/Luhn.rst @@ -5,17 +5,14 @@ This constraint is used to ensure that a credit card number passes the `Luhn algorithm`_. It is useful as a first step to validating a credit card: before communicating with a payment gateway. -+----------------+-----------------------------------------------------------------------+ -| Applies to | :ref:`property or method ` | -+----------------+-----------------------------------------------------------------------+ -| Options | - `groups`_ | -| | - `message`_ | -| | - `payload`_ | -+----------------+-----------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Luhn` | -+----------------+-----------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\LuhnValidator` | -+----------------+-----------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `groups`_ + - `message`_ + - `payload`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\Luhn` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\LuhnValidator` +========== =================================================================== Basic Usage ----------- @@ -102,11 +99,11 @@ The default message supplied when the value does not pass the Luhn check. You can use the following parameters in this message: -+-----------------+-----------------------------+ -| Parameter | Description | -+=================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-----------------+-----------------------------+ +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ value }}`` The current (invalid) value +=============== ============================================================== .. include:: /reference/constraints/_payload-option.rst.inc diff --git a/reference/constraints/NotBlank.rst b/reference/constraints/NotBlank.rst index 44ea6d01008..244cc337007 100644 --- a/reference/constraints/NotBlank.rst +++ b/reference/constraints/NotBlank.rst @@ -5,17 +5,14 @@ Validates that a value is not blank - meaning not equal to a blank string, a blank array, ``false`` or ``null``. To check that a value is not equal to ``null``, see the :doc:`/reference/constraints/NotNull` constraint. -+----------------+------------------------------------------------------------------------+ -| Applies to | :ref:`property or method ` | -+----------------+------------------------------------------------------------------------+ -| Options | - `groups`_ | -| | - `message`_ | -| | - `payload`_ | -+----------------+------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\NotBlank` | -+----------------+------------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\NotBlankValidator` | -+----------------+------------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `groups`_ + - `message`_ + - `payload`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\NotBlank` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\NotBlankValidator` +========== =================================================================== Basic Usage ----------- @@ -93,10 +90,10 @@ This is the message that will be shown if the value is blank. You can use the following parameters in this message: -+-----------------+-----------------------------+ -| Parameter | Description | -+=================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-----------------+-----------------------------+ +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ value }}`` The current (invalid) value +=============== ============================================================== .. include:: /reference/constraints/_payload-option.rst.inc diff --git a/reference/constraints/NotEqualTo.rst b/reference/constraints/NotEqualTo.rst index 7b6e31f8234..73e18fa619a 100644 --- a/reference/constraints/NotEqualTo.rst +++ b/reference/constraints/NotEqualTo.rst @@ -11,19 +11,16 @@ options. To force that a value is equal, see equal. Use :doc:`/reference/constraints/NotIdenticalTo` to compare with ``!==``. -+----------------+-------------------------------------------------------------------------+ -| Applies to | :ref:`property or method` | -+----------------+-------------------------------------------------------------------------+ -| Options | - `value`_ | -| | - `groups`_ | -| | - `message`_ | -| | - `payload`_ | -| | - `propertyPath`_ | -+----------------+-------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\NotEqualTo` | -+----------------+-------------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\NotEqualToValidator`| -+----------------+-------------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `groups`_ + - `message`_ + - `payload`_ + - `propertyPath`_ + - `value`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\NotEqualTo` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\NotEqualToValidator` +========== =================================================================== Basic Usage ----------- @@ -112,8 +109,6 @@ the following: Options ------- -.. include:: /reference/constraints/_comparison-value-option.rst.inc - .. include:: /reference/constraints/_groups-option.rst.inc message @@ -125,16 +120,16 @@ This is the message that will be shown if the value is equal. You can use the following parameters in this message: -+-------------------------------+-----------------------------+ -| Parameter | Description | -+===============================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-------------------------------+-----------------------------+ -| ``{{ compared_value }}`` | The expected value | -+-------------------------------+-----------------------------+ -| ``{{ compared_value_type }}`` | The expected value type | -+-------------------------------+-----------------------------+ +============================= ================================================ +Parameter Description +============================= ================================================ +``{{ compared_value }}`` The expected value +``{{ compared_value_type }}`` The expected value type +``{{ value }}`` The current (invalid) value +============================= ================================================ .. include:: /reference/constraints/_payload-option.rst.inc .. include:: /reference/constraints/_comparison-propertypath-option.rst.inc + +.. include:: /reference/constraints/_comparison-value-option.rst.inc diff --git a/reference/constraints/NotIdenticalTo.rst b/reference/constraints/NotIdenticalTo.rst index def6ea333bc..d49061aa209 100644 --- a/reference/constraints/NotIdenticalTo.rst +++ b/reference/constraints/NotIdenticalTo.rst @@ -11,19 +11,16 @@ the options. To force that a value is identical, see considered not equal. Use :doc:`/reference/constraints/NotEqualTo` to compare with ``!=``. -+----------------+-----------------------------------------------------------------------------+ -| Applies to | :ref:`property or method` | -+----------------+-----------------------------------------------------------------------------+ -| Options | - `value`_ | -| | - `groups`_ | -| | - `message`_ | -| | - `payload`_ | -| | - `propertyPath`_ | -+----------------+-----------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\NotIdenticalTo` | -+----------------+-----------------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\NotIdenticalToValidator`| -+----------------+-----------------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `groups`_ + - `message`_ + - `payload`_ + - `propertyPath`_ + - `value`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\NotIdenticalTo` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\NotIdenticalToValidator` +========== =================================================================== Basic Usage ----------- @@ -113,8 +110,6 @@ The following constraints ensure that: Options ------- -.. include:: /reference/constraints/_comparison-value-option.rst.inc - .. include:: /reference/constraints/_groups-option.rst.inc message @@ -126,16 +121,16 @@ This is the message that will be shown if the value is identical. You can use the following parameters in this message: -+-------------------------------+-----------------------------+ -| Parameter | Description | -+===============================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-------------------------------+-----------------------------+ -| ``{{ compared_value }}`` | The expected value | -+-------------------------------+-----------------------------+ -| ``{{ compared_value_type }}`` | The expected value type | -+-------------------------------+-----------------------------+ +============================= ================================================ +Parameter Description +============================= ================================================ +``{{ compared_value }}`` The expected value +``{{ compared_value_type }}`` The expected value type +``{{ value }}`` The current (invalid) value +============================= ================================================ .. include:: /reference/constraints/_payload-option.rst.inc .. include:: /reference/constraints/_comparison-propertypath-option.rst.inc + +.. include:: /reference/constraints/_comparison-value-option.rst.inc diff --git a/reference/constraints/NotNull.rst b/reference/constraints/NotNull.rst index 716547b8aa5..0bd1c10c397 100644 --- a/reference/constraints/NotNull.rst +++ b/reference/constraints/NotNull.rst @@ -5,17 +5,14 @@ Validates that a value is not strictly equal to ``null``. To ensure that a value is not blank (not a blank string), see the :doc:`/reference/constraints/NotBlank` constraint. -+----------------+-----------------------------------------------------------------------+ -| Applies to | :ref:`property or method ` | -+----------------+-----------------------------------------------------------------------+ -| Options | - `groups`_ | -| | - `message`_ | -| | - `payload`_ | -+----------------+-----------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\NotNull` | -+----------------+-----------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\NotNullValidator` | -+----------------+-----------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `groups`_ + - `message`_ + - `payload`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\NotNull` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\NotNullValidator` +========== =================================================================== Basic Usage ----------- @@ -93,10 +90,10 @@ This is the message that will be shown if the value is ``null``. You can use the following parameters in this message: -+-----------------+-----------------------------+ -| Parameter | Description | -+=================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-----------------+-----------------------------+ +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ value }}`` The current (invalid) value +=============== ============================================================== .. include:: /reference/constraints/_payload-option.rst.inc diff --git a/reference/constraints/Range.rst b/reference/constraints/Range.rst index 8c1e377c541..925b1cbd074 100644 --- a/reference/constraints/Range.rst +++ b/reference/constraints/Range.rst @@ -3,21 +3,18 @@ Range Validates that a given number or ``DateTime`` object is *between* some minimum and maximum. -+----------------+---------------------------------------------------------------------+ -| Applies to | :ref:`property or method ` | -+----------------+---------------------------------------------------------------------+ -| Options | - `min`_ | -| | - `max`_ | -| | - `minMessage`_ | -| | - `maxMessage`_ | -| | - `invalidMessage`_ | -| | - `payload`_ | -| | - `groups`_ | -+----------------+---------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Range` | -+----------------+---------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\RangeValidator` | -+----------------+---------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `groups`_ + - `invalidMessage`_ + - `max`_ + - `maxMessage`_ + - `min`_ + - `minMessage`_ + - `payload`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\Range` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\RangeValidator` +========== =================================================================== Basic Usage ----------- @@ -318,13 +315,23 @@ can check that a delivery date starts within the next five hours like this: Options ------- -min -~~~ +.. include:: /reference/constraints/_groups-option.rst.inc -**type**: ``number`` or ``string`` (date format) +invalidMessage +~~~~~~~~~~~~~~ -This required option is the "min" value. Validation will fail if the given -value is **less** than this min value. +**type**: ``string`` **default**: ``This value should be a valid number.`` + +The message that will be shown if the underlying value is not a number (per +the `is_numeric`_ PHP function). + +You can use the following parameters in this message: + +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ value }}`` The current (invalid) value +=============== ============================================================== max ~~~ @@ -334,24 +341,6 @@ max This required option is the "max" value. Validation will fail if the given value is **greater** than this max value. -minMessage -~~~~~~~~~~ - -**type**: ``string`` **default**: ``This value should be {{ limit }} or more.`` - -The message that will be shown if the underlying value is less than the -`min`_ option. - -You can use the following parameters in this message: - -+-----------------+-----------------------------+ -| Parameter | Description | -+=================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-----------------+-----------------------------+ -| ``{{ limit }}`` | The lower limit | -+-----------------+-----------------------------+ - maxMessage ~~~~~~~~~~ @@ -362,33 +351,39 @@ The message that will be shown if the underlying value is more than the You can use the following parameters in this message: -+-----------------+-----------------------------+ -| Parameter | Description | -+=================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-----------------+-----------------------------+ -| ``{{ limit }}`` | The upper limit | -+-----------------+-----------------------------+ +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ limit }}`` The upper limit +``{{ value }}`` The current (invalid) value +=============== ============================================================== -invalidMessage -~~~~~~~~~~~~~~ +min +~~~ -**type**: ``string`` **default**: ``This value should be a valid number.`` +**type**: ``number`` or ``string`` (date format) -The message that will be shown if the underlying value is not a number (per -the `is_numeric`_ PHP function). +This required option is the "min" value. Validation will fail if the given +value is **less** than this min value. + +minMessage +~~~~~~~~~~ + +**type**: ``string`` **default**: ``This value should be {{ limit }} or more.`` + +The message that will be shown if the underlying value is less than the +`min`_ option. You can use the following parameters in this message: -+-----------------+-----------------------------+ -| Parameter | Description | -+=================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-----------------+-----------------------------+ +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ limit }}`` The lower limit +``{{ value }}`` The current (invalid) value +=============== ============================================================== .. include:: /reference/constraints/_payload-option.rst.inc -.. include:: /reference/constraints/_groups-option.rst.inc - .. _`is_numeric`: https://php.net/manual/en/function.is-numeric.php .. _`accepted by the DateTime constructor`: https://php.net/manual/en/datetime.formats.php diff --git a/reference/constraints/Regex.rst b/reference/constraints/Regex.rst index 31c506b11a8..3259bf66504 100644 --- a/reference/constraints/Regex.rst +++ b/reference/constraints/Regex.rst @@ -3,20 +3,17 @@ Regex Validates that a value matches a regular expression. -+----------------+-----------------------------------------------------------------------+ -| Applies to | :ref:`property or method ` | -+----------------+-----------------------------------------------------------------------+ -| Options | - `pattern`_ | -| | - `groups`_ | -| | - `htmlPattern`_ | -| | - `match`_ | -| | - `message`_ | -| | - `payload`_ | -+----------------+-----------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Regex` | -+----------------+-----------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\RegexValidator` | -+----------------+-----------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `groups`_ + - `htmlPattern`_ + - `match`_ + - `message`_ + - `pattern`_ + - `payload`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\Regex` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\RegexValidator` +========== =================================================================== Basic Usage ----------- @@ -167,17 +164,6 @@ it a custom message: Options ------- -pattern -~~~~~~~ - -**type**: ``string`` [:ref:`default option `] - -This required option is the regular expression pattern that the input will -be matched against. By default, this validator will fail if the input string -does *not* match this regular expression (via the :phpfunction:`preg_match` -PHP function). However, if `match`_ is set to false, then validation will -fail if the input string *does* match this pattern. - .. include:: /reference/constraints/_groups-option.rst.inc htmlPattern @@ -284,10 +270,21 @@ This is the message that will be shown if this validator fails. You can use the following parameters in this message: -+-----------------+-----------------------------+ -| Parameter | Description | -+=================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-----------------+-----------------------------+ +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ value }}`` The current (invalid) value +=============== ============================================================== + +pattern +~~~~~~~ + +**type**: ``string`` [:ref:`default option `] + +This required option is the regular expression pattern that the input will +be matched against. By default, this validator will fail if the input string +does *not* match this regular expression (via the :phpfunction:`preg_match` +PHP function). However, if `match`_ is set to false, then validation will +fail if the input string *does* match this pattern. .. include:: /reference/constraints/_payload-option.rst.inc diff --git a/reference/constraints/Time.rst b/reference/constraints/Time.rst index 24b128ec973..300eba60b1d 100644 --- a/reference/constraints/Time.rst +++ b/reference/constraints/Time.rst @@ -4,17 +4,14 @@ Time Validates that a value is a valid time, meaning a string (or an object that can be cast into a string) that follows a valid ``HH:MM:SS`` format. -+----------------+------------------------------------------------------------------------+ -| Applies to | :ref:`property or method ` | -+----------------+------------------------------------------------------------------------+ -| Options | - `groups`_ | -| | - `message`_ | -| | - `payload`_ | -+----------------+------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Time` | -+----------------+------------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\TimeValidator` | -+----------------+------------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `groups`_ + - `message`_ + - `payload`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\Time` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\TimeValidator` +========== =================================================================== Basic Usage ----------- @@ -100,10 +97,10 @@ This message is shown if the underlying data is not a valid time. You can use the following parameters in this message: -+-----------------+-----------------------------+ -| Parameter | Description | -+=================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-----------------+-----------------------------+ +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ value }}`` The current (invalid) value +=============== ============================================================== .. include:: /reference/constraints/_payload-option.rst.inc diff --git a/reference/constraints/Type.rst b/reference/constraints/Type.rst index 29e66a9bced..c89ee2cf9fd 100644 --- a/reference/constraints/Type.rst +++ b/reference/constraints/Type.rst @@ -5,18 +5,15 @@ Validates that a value is of a specific data type. For example, if a variable should be an array, you can use this constraint with the ``array`` type option to validate this. -+----------------+---------------------------------------------------------------------+ -| Applies to | :ref:`property or method ` | -+----------------+---------------------------------------------------------------------+ -| Options | - :ref:`type ` | -| | - `groups`_ | -| | - `message`_ | -| | - `payload`_ | -+----------------+---------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Type` | -+----------------+---------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\TypeValidator` | -+----------------+---------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `groups`_ + - `message`_ + - `payload`_ + - :ref:`type ` +Class :class:`Symfony\\Component\\Validator\\Constraints\\Type` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\TypeValidator` +========== =================================================================== Basic Usage ----------- @@ -109,6 +106,26 @@ This will check if ``firstName`` is of type ``string`` and that ``age`` is an Options ------- +.. include:: /reference/constraints/_groups-option.rst.inc + +message +~~~~~~~ + +**type**: ``string`` **default**: ``This value should be of type {{ type }}.`` + +The message if the underlying data is not of the given type. + +You can use the following parameters in this message: + +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ type }}`` The expected type +``{{ value }}`` The current (invalid) value +=============== ============================================================== + +.. include:: /reference/constraints/_payload-option.rst.inc + .. _reference-constraint-type-type: type @@ -154,26 +171,5 @@ Also, you can use ``ctype_()`` functions from corresponding Make sure that the proper :phpfunction:`locale ` is set before using one of these. -.. include:: /reference/constraints/_groups-option.rst.inc - -message -~~~~~~~ - -**type**: ``string`` **default**: ``This value should be of type {{ type }}.`` - -The message if the underlying data is not of the given type. - -You can use the following parameters in this message: - -+-----------------+-----------------------------+ -| Parameter | Description | -+=================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-----------------+-----------------------------+ -| ``{{ type }}`` | The expected type | -+-----------------+-----------------------------+ - -.. include:: /reference/constraints/_payload-option.rst.inc - .. _built-in PHP extension: https://php.net/book.ctype.php .. _a list of ctype functions: https://php.net/ref.ctype.php diff --git a/reference/constraints/UniqueEntity.rst b/reference/constraints/UniqueEntity.rst index 6002261e2d3..59afa7f84e4 100644 --- a/reference/constraints/UniqueEntity.rst +++ b/reference/constraints/UniqueEntity.rst @@ -5,23 +5,20 @@ Validates that a particular field (or fields) in a Doctrine entity is (are) unique. This is commonly used, for example, to prevent a new user to register using an email address that already exists in the system. -+----------------+-------------------------------------------------------------------------------------+ -| Applies to | :ref:`class ` | -+----------------+-------------------------------------------------------------------------------------+ -| Options | - `fields`_ | -| | - `groups`_ | -| | - `message`_ | -| | - `em`_ | -| | - `repositoryMethod`_ | -| | - `entityClass`_ | -| | - `errorPath`_ | -| | - `ignoreNull`_ | -| | - `payload`_ | -+----------------+-------------------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Bridge\\Doctrine\\Validator\\Constraints\\UniqueEntity` | -+----------------+-------------------------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Bridge\\Doctrine\\Validator\\Constraints\\UniqueEntityValidator` | -+----------------+-------------------------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`class ` +Options - `em`_ + - `entityClass`_ + - `errorPath`_ + - `fields`_ + - `groups`_ + - `ignoreNull`_ + - `message`_ + - `payload`_ + - `repositoryMethod`_ +Class :class:`Symfony\\Bridge\\Doctrine\\Validator\\Constraints\\UniqueEntity` +Validator :class:`Symfony\\Bridge\\Doctrine\\Validator\\Constraints\\UniqueEntityValidator` +========== =================================================================== Basic Usage ----------- @@ -120,45 +117,6 @@ between all of the constraints in your user table: Options ------- -fields -~~~~~~ - -**type**: ``array`` | ``string`` [:ref:`default option `] - -This required option is the field (or list of fields) on which this entity -should be unique. For example, if you specified both the ``email`` and ``name`` -field in a single ``UniqueEntity`` constraint, then it would enforce that -the combination value is unique (e.g. two users could have the same email, -as long as they don't have the same name also). - -If you need to require two fields to be individually unique (e.g. a unique -``email`` *and* a unique ``username``), you use two ``UniqueEntity`` entries, -each with a single field. - -.. include:: /reference/constraints/_groups-option.rst.inc - -message -~~~~~~~ - -**type**: ``string`` **default**: ``This value is already used.`` - -The message that's displayed when this constraint fails. This message is always -mapped to the first field causing the violation, even when using multiple fields -in the constraint. - -Messages can include the ``{{ value }}`` placeholder to display a string -representation of the invalid entity. If the entity doesn't define the -``__toString()`` method, the following generic value will be used: *"Object of -class __CLASS__ identified by "* - -You can use the following parameters in this message: - -+-----------------+-----------------------------+ -| Parameter | Description | -+=================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-----------------+-----------------------------+ - em ~~ @@ -169,17 +127,6 @@ the uniqueness. If it's left blank, the correct entity manager will be determined for this class. For that reason, this option should probably not need to be used. -repositoryMethod -~~~~~~~~~~~~~~~~ - -**type**: ``string`` **default**: ``findBy`` - -The name of the repository method used to determine the uniqueness. If it's left -blank, ``findBy()`` will be used. The method receives as its argument a -``fieldName => value`` associative array (where ``fieldName`` is each of the -fields configured in the ``fields`` option). The method should return a -`countable PHP variable`_. - entityClass ~~~~~~~~~~~ @@ -289,6 +236,23 @@ Consider this example: Now, the message would be bound to the ``port`` field with this configuration. +fields +~~~~~~ + +**type**: ``array`` | ``string`` [:ref:`default option `] + +This required option is the field (or list of fields) on which this entity +should be unique. For example, if you specified both the ``email`` and ``name`` +field in a single ``UniqueEntity`` constraint, then it would enforce that +the combination value is unique (e.g. two users could have the same email, +as long as they don't have the same name also). + +If you need to require two fields to be individually unique (e.g. a unique +``email`` *and* a unique ``username``), you use two ``UniqueEntity`` entries, +each with a single field. + +.. include:: /reference/constraints/_groups-option.rst.inc + ignoreNull ~~~~~~~~~~ @@ -299,7 +263,40 @@ entities to have a ``null`` value for a field without failing validation. If set to ``false``, only one ``null`` value is allowed - if a second entity also has a ``null`` value, validation would fail. +message +~~~~~~~ + +**type**: ``string`` **default**: ``This value is already used.`` + +The message that's displayed when this constraint fails. This message is always +mapped to the first field causing the violation, even when using multiple fields +in the constraint. + +Messages can include the ``{{ value }}`` placeholder to display a string +representation of the invalid entity. If the entity doesn't define the +``__toString()`` method, the following generic value will be used: *"Object of +class __CLASS__ identified by "* + +You can use the following parameters in this message: + +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ value }}`` The current (invalid) value +=============== ============================================================== + .. include:: /reference/constraints/_payload-option.rst.inc +repositoryMethod +~~~~~~~~~~~~~~~~ + +**type**: ``string`` **default**: ``findBy`` + +The name of the repository method used to determine the uniqueness. If it's left +blank, ``findBy()`` will be used. The method receives as its argument a +``fieldName => value`` associative array (where ``fieldName`` is each of the +fields configured in the ``fields`` option). The method should return a +`countable PHP variable`_. + .. _`race conditions`: https://en.wikipedia.org/wiki/Race_condition .. _`countable PHP variable`: https://php.net/manual/function.is-countable.php diff --git a/reference/constraints/Url.rst b/reference/constraints/Url.rst index 01d2339dd30..aa1d33641ee 100644 --- a/reference/constraints/Url.rst +++ b/reference/constraints/Url.rst @@ -3,21 +3,18 @@ Url Validates that a value is a valid URL string. -+----------------+---------------------------------------------------------------------+ -| Applies to | :ref:`property or method ` | -+----------------+---------------------------------------------------------------------+ -| Options | - `groups`_ | -| | - `message`_ | -| | - `protocols`_ | -| | - `payload`_ | -| | - `checkDNS`_ | -| | - `dnsMessage`_ | -| | - `relativeProtocol`_ | -+----------------+---------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Url` | -+----------------+---------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\UrlValidator` | -+----------------+---------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `checkDNS`_ + - `dnsMessage`_ + - `groups`_ + - `message`_ + - `payload`_ + - `protocols`_ + - `relativeProtocol`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\Url` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\UrlValidator` +========== =================================================================== Basic Usage ----------- @@ -83,22 +80,22 @@ Basic Usage Options ------- -.. include:: /reference/constraints/_groups-option.rst.inc - -message -~~~~~~~ +checkDNS +~~~~~~~~ -**type**: ``string`` **default**: ``This value is not a valid URL.`` +**type**: ``boolean`` **default**: ``false`` -This message is shown if the URL is invalid. +.. versionadded:: 4.1 -You can use the following parameters in this message: + This option was deprecated in Symfony 4.1 and will be removed in Symfony 5.0, + because checking the DNS records is not reliable enough to validate the + existence of the host. Use the :phpfunction:`checkdnsrr` PHP function if you + still want to use this kind of validation. -+-----------------+-----------------------------+ -| Parameter | Description | -+=================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-----------------+-----------------------------+ +By default, this constraint just validates the syntax of the given URL. If you +also need to check whether the associated host exists, set the ``checkDNS`` +option to the value of any of the ``CHECK_DNS_TYPE_*`` constants in the +:class:`Symfony\\Component\\Validator\\Constraints\\Url` class: .. configuration-block:: @@ -113,7 +110,7 @@ You can use the following parameters in this message: { /** * @Assert\Url( - * message = "The url '{{ value }}' is not a valid url", + * checkDNS = "ANY" * ) */ protected $bioUrl; @@ -125,8 +122,7 @@ You can use the following parameters in this message: App\Entity\Author: properties: bioUrl: - - Url: - message: The url "{{ value }}" is not a valid url. + - Url: { checkDNS: 'ANY' } .. code-block:: xml @@ -139,7 +135,7 @@ You can use the following parameters in this message: - + @@ -158,19 +154,28 @@ You can use the following parameters in this message: public static function loadValidatorMetadata(ClassMetadata $metadata) { $metadata->addPropertyConstraint('bioUrl', new Assert\Url([ - 'message' => 'The url "{{ value }}" is not a valid url.', + 'checkDNS' => Assert\Url::CHECK_DNS_TYPE_ANY, ])); } } -protocols -~~~~~~~~~ +This option uses the :phpfunction:`checkdnsrr` PHP function to check the validity +of the DNS record corresponding to the host associated with the given URL. -**type**: ``array`` **default**: ``['http', 'https']`` +dnsMessage +~~~~~~~~~~ -The protocols considered to be valid for the URL. For example, if you also consider -the ``ftp://`` type URLs to be valid, redefine the ``protocols`` array, listing -``http``, ``https``, and also ``ftp``. +**type**: ``string`` **default**: ``The host could not be resolved.`` + +.. versionadded:: 4.1 + + This option was deprecated in Symfony 4.1 and will be removed in Symfony 5.0, + because checking the DNS records is not reliable enough to validate the + existence of the host. Use the :phpfunction:`checkdnsrr` PHP function if you + still want to use this kind of validation. + +This message is shown when the ``checkDNS`` option is set to ``true`` and the +DNS check failed. .. configuration-block:: @@ -185,7 +190,7 @@ the ``ftp://`` type URLs to be valid, redefine the ``protocols`` array, listing { /** * @Assert\Url( - * protocols = {"http", "https", "ftp"} + * dnsMessage = "The host '{{ value }}' could not be resolved." * ) */ protected $bioUrl; @@ -197,7 +202,7 @@ the ``ftp://`` type URLs to be valid, redefine the ``protocols`` array, listing App\Entity\Author: properties: bioUrl: - - Url: { protocols: [http, https, ftp] } + - Url: { dnsMessage: 'The host "{{ value }}" could not be resolved.' } .. code-block:: xml @@ -210,11 +215,7 @@ the ``ftp://`` type URLs to be valid, redefine the ``protocols`` array, listing - + @@ -233,29 +234,27 @@ the ``ftp://`` type URLs to be valid, redefine the ``protocols`` array, listing public static function loadValidatorMetadata(ClassMetadata $metadata) { $metadata->addPropertyConstraint('bioUrl', new Assert\Url([ - 'protocols' => ['http', 'https', 'ftp'], + 'dnsMessage' => 'The host "{{ value }}" could not be resolved.', ])); } } -.. include:: /reference/constraints/_payload-option.rst.inc +.. include:: /reference/constraints/_groups-option.rst.inc -checkDNS -~~~~~~~~ +message +~~~~~~~ -**type**: ``boolean`` **default**: ``false`` +**type**: ``string`` **default**: ``This value is not a valid URL.`` -.. versionadded:: 4.1 +This message is shown if the URL is invalid. - This option was deprecated in Symfony 4.1 and will be removed in Symfony 5.0, - because checking the DNS records is not reliable enough to validate the - existence of the host. Use the :phpfunction:`checkdnsrr` PHP function if you - still want to use this kind of validation. +You can use the following parameters in this message: -By default, this constraint just validates the syntax of the given URL. If you -also need to check whether the associated host exists, set the ``checkDNS`` -option to the value of any of the ``CHECK_DNS_TYPE_*`` constants in the -:class:`Symfony\\Component\\Validator\\Constraints\\Url` class: +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ value }}`` The current (invalid) value +=============== ============================================================== .. configuration-block:: @@ -270,7 +269,7 @@ option to the value of any of the ``CHECK_DNS_TYPE_*`` constants in the { /** * @Assert\Url( - * checkDNS = "ANY" + * message = "The url '{{ value }}' is not a valid url", * ) */ protected $bioUrl; @@ -282,7 +281,8 @@ option to the value of any of the ``CHECK_DNS_TYPE_*`` constants in the App\Entity\Author: properties: bioUrl: - - Url: { checkDNS: 'ANY' } + - Url: + message: The url "{{ value }}" is not a valid url. .. code-block:: xml @@ -295,7 +295,7 @@ option to the value of any of the ``CHECK_DNS_TYPE_*`` constants in the - + @@ -314,28 +314,21 @@ option to the value of any of the ``CHECK_DNS_TYPE_*`` constants in the public static function loadValidatorMetadata(ClassMetadata $metadata) { $metadata->addPropertyConstraint('bioUrl', new Assert\Url([ - 'checkDNS' => Assert\Url::CHECK_DNS_TYPE_ANY, + 'message' => 'The url "{{ value }}" is not a valid url.', ])); } } -This option uses the :phpfunction:`checkdnsrr` PHP function to check the validity -of the DNS record corresponding to the host associated with the given URL. - -dnsMessage -~~~~~~~~~~ - -**type**: ``string`` **default**: ``The host could not be resolved.`` +.. include:: /reference/constraints/_payload-option.rst.inc -.. versionadded:: 4.1 +protocols +~~~~~~~~~ - This option was deprecated in Symfony 4.1 and will be removed in Symfony 5.0, - because checking the DNS records is not reliable enough to validate the - existence of the host. Use the :phpfunction:`checkdnsrr` PHP function if you - still want to use this kind of validation. +**type**: ``array`` **default**: ``['http', 'https']`` -This message is shown when the ``checkDNS`` option is set to ``true`` and the -DNS check failed. +The protocols considered to be valid for the URL. For example, if you also consider +the ``ftp://`` type URLs to be valid, redefine the ``protocols`` array, listing +``http``, ``https``, and also ``ftp``. .. configuration-block:: @@ -350,7 +343,7 @@ DNS check failed. { /** * @Assert\Url( - * dnsMessage = "The host '{{ value }}' could not be resolved." + * protocols = {"http", "https", "ftp"} * ) */ protected $bioUrl; @@ -362,7 +355,7 @@ DNS check failed. App\Entity\Author: properties: bioUrl: - - Url: { dnsMessage: 'The host "{{ value }}" could not be resolved.' } + - Url: { protocols: [http, https, ftp] } .. code-block:: xml @@ -375,7 +368,11 @@ DNS check failed. - + @@ -394,7 +391,7 @@ DNS check failed. public static function loadValidatorMetadata(ClassMetadata $metadata) { $metadata->addPropertyConstraint('bioUrl', new Assert\Url([ - 'dnsMessage' => 'The host "{{ value }}" could not be resolved.', + 'protocols' => ['http', 'https', 'ftp'], ])); } } diff --git a/reference/constraints/UserPassword.rst b/reference/constraints/UserPassword.rst index c1f7e88a304..6cc554d7457 100644 --- a/reference/constraints/UserPassword.rst +++ b/reference/constraints/UserPassword.rst @@ -10,17 +10,14 @@ password, but needs to enter their old password for security. This should **not** be used to validate a login form, since this is done automatically by the security system. -+----------------+--------------------------------------------------------------------------------------------+ -| Applies to | :ref:`property or method ` | -+----------------+--------------------------------------------------------------------------------------------+ -| Options | - `groups`_ | -| | - `message`_ | -| | - `payload`_ | -+----------------+--------------------------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Security\\Core\\Validator\\Constraints\\UserPassword` | -+----------------+--------------------------------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Security\\Core\\Validator\\Constraints\\UserPasswordValidator` | -+----------------+--------------------------------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `groups`_ + - `message`_ + - `payload`_ +Class :class:`Symfony\\Component\\Security\\Core\\Validator\\Constraints\\UserPassword` +Validator :class:`Symfony\\Component\\Security\\Core\\Validator\\Constraints\\UserPasswordValidator` +========== =================================================================== Basic Usage ----------- diff --git a/reference/constraints/Uuid.rst b/reference/constraints/Uuid.rst index c8e36d2105f..7a009688383 100644 --- a/reference/constraints/Uuid.rst +++ b/reference/constraints/Uuid.rst @@ -6,19 +6,16 @@ By default, this will validate the format according to the RFC's guidelines, but be relaxed to accept non-standard UUIDs that other systems (like PostgreSQL) accept. UUID versions can also be restricted using a whitelist. -+----------------+---------------------------------------------------------------------+ -| Applies to | :ref:`property or method ` | -+----------------+---------------------------------------------------------------------+ -| Options | - `groups`_ | -| | - `message`_ | -| | - `strict`_ | -| | - `versions`_ | -| | - `payload`_ | -+----------------+---------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Uuid` | -+----------------+---------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\UuidValidator` | -+----------------+---------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `groups`_ + - `message`_ + - `payload`_ + - `strict`_ + - `versions`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\Uuid` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\UuidValidator` +========== =================================================================== Basic Usage ----------- @@ -95,11 +92,13 @@ This message is shown if the string is not a valid UUID. You can use the following parameters in this message: -+-----------------+-----------------------------+ -| Parameter | Description | -+=================+=============================+ -| ``{{ value }}`` | The current (invalid) value | -+-----------------+-----------------------------+ +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ value }}`` The current (invalid) value +=============== ============================================================== + +.. include:: /reference/constraints/_payload-option.rst.inc strict ~~~~~~ @@ -130,8 +129,6 @@ The following PHP constants can also be used: All five versions are allowed by default. -.. include:: /reference/constraints/_payload-option.rst.inc - .. _`Universally unique identifier (UUID)`: http://en.wikipedia.org/wiki/Universally_unique_identifier .. _`RFC 4122`: http://tools.ietf.org/html/rfc4122 .. _`UUID versions`: http://en.wikipedia.org/wiki/Universally_unique_identifier#Variants_and_versions diff --git a/reference/constraints/Valid.rst b/reference/constraints/Valid.rst index a80e63dc4b8..87fd5a99bc8 100644 --- a/reference/constraints/Valid.rst +++ b/reference/constraints/Valid.rst @@ -5,15 +5,13 @@ This constraint is used to enable validation on objects that are embedded as properties on an object being validated. This allows you to validate an object and all sub-objects associated with it. -+----------------+---------------------------------------------------------------------+ -| Applies to | :ref:`property or method ` | -+----------------+---------------------------------------------------------------------+ -| Options | - `traverse`_ | -| | - `payload`_ | -| | - `groups`_ | -+----------------+---------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Valid` | -+----------------+---------------------------------------------------------------------+ +========== =================================================================== +Applies to :ref:`property or method ` +Options - `groups`_ + - `payload`_ + - `traverse`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\Valid` +========== =================================================================== .. include:: /reference/forms/types/options/_error_bubbling_hint.rst.inc @@ -257,6 +255,10 @@ the validation of the ``Address`` fields failed. Options ------- +.. include:: /reference/constraints/_groups-option.rst.inc + +.. include:: /reference/constraints/_payload-option.rst.inc + traverse ~~~~~~~~ @@ -265,7 +267,3 @@ traverse If this constraint is applied to a property that holds an array of objects, then each object in that array will be validated only if this option is set to ``true``. - -.. include:: /reference/constraints/_payload-option.rst.inc - -.. include:: /reference/constraints/_groups-option.rst.inc