Skip to content

Commit

Permalink
document the validation payload option
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed Dec 31, 2014
1 parent 640b29e commit 9416d6e
Show file tree
Hide file tree
Showing 45 changed files with 147 additions and 10 deletions.
3 changes: 3 additions & 0 deletions reference/constraints/All.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ you to apply a collection of constraints to each element of the array.
| Applies to | :ref:`property or method <validation-property-target>` |
+----------------+------------------------------------------------------------------------+
| Options | - `constraints`_ |
| | - `payload`_ |
+----------------+------------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\All` |
+----------------+------------------------------------------------------------------------+
Expand Down Expand Up @@ -107,3 +108,5 @@ constraints

This required option is the array of validation constraints that you want
to apply to each element of the underlying array.

.. include:: /reference/constraints/_payload-option.rst.inc
3 changes: 3 additions & 0 deletions reference/constraints/Blank.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ blank, see :doc:`/reference/constraints/NotBlank`.
| Applies to | :ref:`property or method <validation-property-target>` |
+----------------+-----------------------------------------------------------------------+
| Options | - `message`_ |
| | - `payload`_ |
+----------------+-----------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Blank` |
+----------------+-----------------------------------------------------------------------+
Expand Down Expand Up @@ -87,3 +88,5 @@ message
**type**: ``string`` **default**: ``This value should be blank.``

This is the message that will be shown if the value is not blank.

.. include:: /reference/constraints/_payload-option.rst.inc
3 changes: 3 additions & 0 deletions reference/constraints/Callback.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ can do anything, including creating and assigning validation errors.
| Applies to | :ref:`class <validation-class-target>` |
+----------------+------------------------------------------------------------------------+
| Options | - :ref:`callback <callback-option>` |
| | - `payload`_ |
+----------------+------------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Callback` |
+----------------+------------------------------------------------------------------------+
Expand Down Expand Up @@ -302,3 +303,5 @@ instance as only argument.
Static or closure callbacks receive the validated object as the first argument
and the :class:`Symfony\\Component\\Validator\\ExecutionContextInterface`
instance as the second argument.

.. include:: /reference/constraints/_payload-option.rst.inc
3 changes: 3 additions & 0 deletions reference/constraints/CardScheme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ through a payment gateway.
+----------------+--------------------------------------------------------------------------+
| Options | - `schemes`_ |
| | - `message`_ |
| | - `payload`_ |
+----------------+--------------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\CardScheme` |
+----------------+--------------------------------------------------------------------------+
Expand Down Expand Up @@ -124,4 +125,6 @@ message

The message shown when the value does not pass the ``CardScheme`` check.

.. include:: /reference/constraints/_payload-option.rst.inc

.. _`Wikipedia: Issuer identification number (IIN)`: http://en.wikipedia.org/wiki/Bank_card_number#Issuer_identification_number_.28IIN.29
15 changes: 9 additions & 6 deletions reference/constraints/Choice.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ an array of items is one of those valid choices.
| | - `minMessage`_ |
| | - `maxMessage`_ |
| | - `strict`_ |
| | - `payload`_ |
+----------------+-----------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Choice` |
+----------------+-----------------------------------------------------------------------+
Expand Down Expand Up @@ -89,11 +90,11 @@ If your valid choice list is simple, you can pass them in directly via the
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Constraints as Assert;
class Author
{
protected $gender;
public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata->addPropertyConstraint('gender', new Assert\Choice(array(
Expand Down Expand Up @@ -176,11 +177,11 @@ constraint.
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Constraints as Assert;
class Author
{
protected $gender;
public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata->addPropertyConstraint('gender', new Assert\Choice(array(
Expand Down Expand Up @@ -244,11 +245,11 @@ you can pass the class name and the method as an array.
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Constraints as Assert;
class Author
{
protected $gender;
public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata->addPropertyConstraint('gender', new Assert\Choice(array(
Expand Down Expand Up @@ -349,3 +350,5 @@ strict
If true, the validator will also check the type of the input value. Specifically,
this value is passed to as the third argument to the PHP :phpfunction:`in_array` method
when checking to see if a value is in the valid choices array.

.. include:: /reference/constraints/_payload-option.rst.inc
3 changes: 3 additions & 0 deletions reference/constraints/Collection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and that extra keys are not present.
| | - `extraFieldsMessage`_ |
| | - `allowMissingFields`_ |
| | - `missingFieldsMessage`_ |
| | - `payload`_ |
+----------------+--------------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Collection` |
+----------------+--------------------------------------------------------------------------+
Expand Down Expand Up @@ -328,3 +329,5 @@ missingFieldsMessage

The message shown if `allowMissingFields`_ is false and one or more fields
are missing from the underlying collection.

.. include:: /reference/constraints/_payload-option.rst.inc
3 changes: 3 additions & 0 deletions reference/constraints/Count.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ element count is *between* some minimum and maximum value.
| | - `minMessage`_ |
| | - `maxMessage`_ |
| | - `exactMessage`_ |
| | - `payload`_ |
+----------------+---------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Count` |
+----------------+---------------------------------------------------------------------+
Expand Down Expand Up @@ -139,3 +140,5 @@ exactMessage

The message that will be shown if min and max values are equal and the underlying collection elements
count is not exactly this value.

.. include:: /reference/constraints/_payload-option.rst.inc
3 changes: 3 additions & 0 deletions reference/constraints/Country.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Validates that a value is a valid `ISO 3166-1 alpha-2`_ country code.
| Applies to | :ref:`property or method <validation-property-target>` |
+----------------+------------------------------------------------------------------------+
| Options | - `message`_ |
| | - `payload`_ |
+----------------+------------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Country` |
+----------------+------------------------------------------------------------------------+
Expand Down Expand Up @@ -82,4 +83,6 @@ message

This message is shown if the string is not a valid country code.

.. include:: /reference/constraints/_payload-option.rst.inc

.. _`ISO 3166-1 alpha-2`: http://en.wikipedia.org/wiki/ISO_3166-1#Current_codes
3 changes: 3 additions & 0 deletions reference/constraints/Currency.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Validates that a value is a valid `3-letter ISO 4217`_ currency name.
| Applies to | :ref:`property or method<validation-property-target>` |
+----------------+---------------------------------------------------------------------------+
| Options | - `message`_ |
| | - `payload`_ |
+----------------+---------------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Currency` |
+----------------+---------------------------------------------------------------------------+
Expand Down Expand Up @@ -88,4 +89,6 @@ message

This is the message that will be shown if the value is not a valid currency.

.. include:: /reference/constraints/_payload-option.rst.inc

.. _`3-letter ISO 4217`: http://en.wikipedia.org/wiki/ISO_4217
3 changes: 3 additions & 0 deletions reference/constraints/Date.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ valid YYYY-MM-DD format.
| Applies to | :ref:`property or method <validation-property-target>` |
+----------------+--------------------------------------------------------------------+
| Options | - `message`_ |
| | - `payload`_ |
+----------------+--------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Date` |
+----------------+--------------------------------------------------------------------+
Expand Down Expand Up @@ -83,3 +84,5 @@ message
**type**: ``string`` **default**: ``This value is not a valid date.``

This message is shown if the underlying data is not a valid date.

.. include:: /reference/constraints/_payload-option.rst.inc
3 changes: 3 additions & 0 deletions reference/constraints/DateTime.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ a valid YYYY-MM-DD HH:MM:SS format.
| Applies to | :ref:`property or method <validation-property-target>` |
+----------------+------------------------------------------------------------------------+
| Options | - `message`_ |
| | - `payload`_ |
+----------------+------------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\DateTime` |
+----------------+------------------------------------------------------------------------+
Expand Down Expand Up @@ -83,3 +84,5 @@ message
**type**: ``string`` **default**: ``This value is not a valid datetime.``

This message is shown if the underlying data is not a valid datetime.

.. include:: /reference/constraints/_payload-option.rst.inc
5 changes: 4 additions & 1 deletion reference/constraints/Email.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ cast to a string before being validated.
| | - `message`_ |
| | - `checkMX`_ |
| | - `checkHost`_ |
| | - `payload`_ |
+----------------+---------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Email` |
+----------------+---------------------------------------------------------------------+
Expand Down Expand Up @@ -99,7 +100,7 @@ strict
**type**: ``boolean`` **default**: ``false``

When false, the email will be validated against a simple regular expression.
If true, then the `egulias/email-validator`_ library is required to perform
If true, then the `egulias/email-validator`_ library is required to perform
an RFC compliant validation.

message
Expand All @@ -126,4 +127,6 @@ 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.

.. include:: /reference/constraints/_payload-option.rst.inc

.. _egulias/email-validator: https://packagist.org/packages/egulias/email-validator
3 changes: 3 additions & 0 deletions reference/constraints/EqualTo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ force that a value is *not* equal, see :doc:`/reference/constraints/NotEqualTo`.
+----------------+-----------------------------------------------------------------------+
| Options | - `value`_ |
| | - `message`_ |
| | - `payload`_ |
+----------------+-----------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\EqualTo` |
+----------------+-----------------------------------------------------------------------+
Expand Down Expand Up @@ -104,3 +105,5 @@ message
**type**: ``string`` **default**: ``This value should be equal to {{ compared_value }}.``

This is the message that will be shown if the value is not equal.

.. include:: /reference/constraints/_payload-option.rst.inc
3 changes: 3 additions & 0 deletions reference/constraints/Expression.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ gives you similar flexibility.
+----------------+-----------------------------------------------------------------------------------------------+
| Options | - :ref:`expression <reference-constraint-expression-option>` |
| | - `message`_ |
| | - `payload`_ |
+----------------+-----------------------------------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Expression` |
+----------------+-----------------------------------------------------------------------------------------------+
Expand Down Expand Up @@ -258,3 +259,5 @@ message
**type**: ``string`` **default**: ``This value is not valid.``

The default message supplied when the expression evaluates to false.

.. include:: /reference/constraints/_payload-option.rst.inc
3 changes: 3 additions & 0 deletions reference/constraints/False.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Also see :doc:`True <True>`.
| Applies to | :ref:`property or method <validation-property-target>` |
+----------------+---------------------------------------------------------------------+
| Options | - `message`_ |
| | - `payload`_ |
+----------------+---------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\False` |
+----------------+---------------------------------------------------------------------+
Expand Down Expand Up @@ -115,3 +116,5 @@ message
**type**: ``string`` **default**: ``This value should be false.``

This message is shown if the underlying data is not false.

.. include:: /reference/constraints/_payload-option.rst.inc
2 changes: 2 additions & 0 deletions reference/constraints/File.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ form type.
| | - `uploadIniSizeErrorMessage`_ |
| | - `uploadFormSizeErrorMessage`_ |
| | - `uploadErrorMessage`_ |
| | - `payload`_ |
+----------------+---------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\File` |
+----------------+---------------------------------------------------------------------+
Expand Down Expand Up @@ -276,6 +277,7 @@ The message that is displayed if the uploaded file could not be uploaded
for some unknown reason, such as the file upload failed or it couldn't be written
to disk.

.. include:: /reference/constraints/_payload-option.rst.inc

.. _`IANA website`: http://www.iana.org/assignments/media-types/index.html
.. _`Wikipedia: Binary prefix`: http://en.wikipedia.org/wiki/Binary_prefix
3 changes: 3 additions & 0 deletions reference/constraints/GreaterThan.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ than another value, see :doc:`/reference/constraints/LessThan`.
+----------------+---------------------------------------------------------------------------+
| Options | - `value`_ |
| | - `message`_ |
| | - `payload`_ |
+----------------+---------------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\GreaterThan` |
+----------------+---------------------------------------------------------------------------+
Expand Down Expand Up @@ -101,3 +102,5 @@ message

This is the message that will be shown if the value is not greater than the
comparison value.

.. include:: /reference/constraints/_payload-option.rst.inc
3 changes: 3 additions & 0 deletions reference/constraints/GreaterThanOrEqual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ the options. To force that a value is greater than another value, see
+----------------+----------------------------------------------------------------------------------+
| Options | - `value`_ |
| | - `message`_ |
| | - `payload`_ |
+----------------+----------------------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\GreaterThanOrEqual` |
+----------------+----------------------------------------------------------------------------------+
Expand Down Expand Up @@ -100,3 +101,5 @@ message

This is the message that will be shown if the value is not greater than or equal
to the comparison value.

.. include:: /reference/constraints/_payload-option.rst.inc
3 changes: 3 additions & 0 deletions reference/constraints/Iban.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ transcription errors.
| Applies to | :ref:`property or method<validation-property-target>` |
+----------------+-----------------------------------------------------------------------+
| Options | - `message`_ |
| | - `payload`_ |
+----------------+-----------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Iban` |
+----------------+-----------------------------------------------------------------------+
Expand Down Expand Up @@ -98,4 +99,6 @@ message

The default message supplied when the value does not pass the Iban check.

.. include:: /reference/constraints/_payload-option.rst.inc

.. _`International Bank Account Number (IBAN)`: http://en.wikipedia.org/wiki/International_Bank_Account_Number

0 comments on commit 9416d6e

Please sign in to comment.