diff --git a/book/forms.rst b/book/forms.rst index bab0af3330f..0119aa4575a 100644 --- a/book/forms.rst +++ b/book/forms.rst @@ -344,17 +344,6 @@ object. .. configuration-block:: - .. code-block:: yaml - - # AppBundle/Resources/config/validation.yml - AppBundle\Entity\Task: - properties: - task: - - NotBlank: ~ - dueDate: - - NotBlank: ~ - - Type: \DateTime - .. code-block:: php-annotations // AppBundle/Entity/Task.php @@ -374,6 +363,17 @@ object. protected $dueDate; } + .. code-block:: yaml + + # AppBundle/Resources/config/validation.yml + AppBundle\Entity\Task: + properties: + task: + - NotBlank: ~ + dueDate: + - NotBlank: ~ + - Type: \DateTime + .. code-block:: xml diff --git a/cookbook/doctrine/file_uploads.rst b/cookbook/doctrine/file_uploads.rst index ab52ae4c940..f9a2d7bb4d9 100644 --- a/cookbook/doctrine/file_uploads.rst +++ b/cookbook/doctrine/file_uploads.rst @@ -152,15 +152,6 @@ rules:: .. configuration-block:: - .. code-block:: yaml - - # src/AppBundle/Resources/config/validation.yml - AppBundle\Entity\Document: - properties: - file: - - File: - maxSize: 6000000 - .. code-block:: php-annotations // src/AppBundle/Entity/Document.php @@ -179,6 +170,15 @@ rules:: // ... } + .. code-block:: yaml + + # src/AppBundle/Resources/config/validation.yml + AppBundle\Entity\Document: + properties: + file: + - File: + maxSize: 6000000 + .. code-block:: xml diff --git a/cookbook/validation/custom_constraint.rst b/cookbook/validation/custom_constraint.rst index 0220d858f8a..b2a27b61216 100644 --- a/cookbook/validation/custom_constraint.rst +++ b/cookbook/validation/custom_constraint.rst @@ -89,15 +89,6 @@ Using custom validators is very easy, just as the ones provided by Symfony itsel .. configuration-block:: - .. code-block:: yaml - - # src/AppBundle/Resources/config/validation.yml - AppBundle\Entity\AcmeEntity: - properties: - name: - - NotBlank: ~ - - AppBundle\Validator\Constraints\ContainsAlphanumeric: ~ - .. code-block:: php-annotations // src/AppBundle/Entity/AcmeEntity.php @@ -117,6 +108,15 @@ Using custom validators is very easy, just as the ones provided by Symfony itsel // ... } + .. code-block:: yaml + + # src/AppBundle/Resources/config/validation.yml + AppBundle\Entity\AcmeEntity: + properties: + name: + - NotBlank: ~ + - AppBundle\Validator\Constraints\ContainsAlphanumeric: ~ + .. code-block:: xml @@ -237,13 +237,6 @@ not to the property: .. configuration-block:: - .. code-block:: yaml - - # src/AppBundle/Resources/config/validation.yml - AppBundle\Entity\AcmeEntity: - constraints: - - AppBundle\Validator\Constraints\ContainsAlphanumeric: ~ - .. code-block:: php-annotations /** @@ -254,6 +247,13 @@ not to the property: // ... } + .. code-block:: yaml + + # src/AppBundle/Resources/config/validation.yml + AppBundle\Entity\AcmeEntity: + constraints: + - AppBundle\Validator\Constraints\ContainsAlphanumeric: ~ + .. code-block:: xml diff --git a/reference/constraints/All.rst b/reference/constraints/All.rst index 5f5aa859a3d..7c3a2f2a311 100644 --- a/reference/constraints/All.rst +++ b/reference/constraints/All.rst @@ -22,17 +22,6 @@ entry in that array: .. configuration-block:: - .. code-block:: yaml - - # src/Acme/UserBundle/Resources/config/validation.yml - Acme\UserBundle\Entity\User: - properties: - favoriteColors: - - All: - - NotBlank: ~ - - Length: - min: 5 - .. code-block:: php-annotations // src/Acme/UserBundle/Entity/User.php @@ -51,6 +40,17 @@ entry in that array: protected $favoriteColors = array(); } + .. code-block:: yaml + + # src/Acme/UserBundle/Resources/config/validation.yml + Acme\UserBundle\Entity\User: + properties: + favoriteColors: + - All: + - NotBlank: ~ + - Length: + min: 5 + .. code-block:: xml diff --git a/reference/constraints/Blank.rst b/reference/constraints/Blank.rst index 5679aa5bf56..1f85334443f 100644 --- a/reference/constraints/Blank.rst +++ b/reference/constraints/Blank.rst @@ -24,14 +24,6 @@ of an ``Author`` class were blank, you could do the following: .. configuration-block:: - .. code-block:: yaml - - # src/Acme/BlogBundle/Resources/config/validation.yml - Acme\BlogBundle\Entity\Author: - properties: - firstName: - - Blank: ~ - .. code-block:: php-annotations // src/Acme/BlogBundle/Entity/Author.php @@ -47,6 +39,14 @@ of an ``Author`` class were blank, you could do the following: protected $firstName; } + .. code-block:: yaml + + # src/Acme/BlogBundle/Resources/config/validation.yml + Acme\BlogBundle\Entity\Author: + properties: + firstName: + - Blank: ~ + .. code-block:: xml diff --git a/reference/constraints/Callback.rst b/reference/constraints/Callback.rst index f6d570962d4..491963cd508 100644 --- a/reference/constraints/Callback.rst +++ b/reference/constraints/Callback.rst @@ -32,14 +32,6 @@ Setup .. configuration-block:: - .. code-block:: yaml - - # src/Acme/BlogBundle/Resources/config/validation.yml - Acme\BlogBundle\Entity\Author: - constraints: - - Callback: - methods: [isAuthorValid] - .. code-block:: php-annotations // src/Acme/BlogBundle/Entity/Author.php @@ -54,6 +46,14 @@ Setup { } + .. code-block:: yaml + + # src/Acme/BlogBundle/Resources/config/validation.yml + Acme\BlogBundle\Entity\Author: + constraints: + - Callback: + methods: [isAuthorValid] + .. code-block:: xml @@ -139,15 +139,6 @@ process. Each method can be one of the following formats: .. configuration-block:: - .. code-block:: yaml - - # src/Acme/BlogBundle/Resources/config/validation.yml - Acme\BlogBundle\Entity\Author: - constraints: - - Callback: - methods: - - [Acme\BlogBundle\MyStaticValidatorClass, isAuthorValid] - .. code-block:: php-annotations // src/Acme/BlogBundle/Entity/Author.php @@ -162,6 +153,15 @@ process. Each method can be one of the following formats: { } + .. code-block:: yaml + + # src/Acme/BlogBundle/Resources/config/validation.yml + Acme\BlogBundle\Entity\Author: + constraints: + - Callback: + methods: + - [Acme\BlogBundle\MyStaticValidatorClass, isAuthorValid] + .. code-block:: xml diff --git a/reference/constraints/CardScheme.rst b/reference/constraints/CardScheme.rst index f8d706e665a..7078ca4635c 100644 --- a/reference/constraints/CardScheme.rst +++ b/reference/constraints/CardScheme.rst @@ -27,6 +27,21 @@ on an object that will contain a credit card number. .. configuration-block:: + .. code-block:: php-annotations + + // src/Acme/SubscriptionBundle/Entity/Transaction.php + namespace Acme\SubscriptionBundle\Entity\Transaction; + + use Symfony\Component\Validator\Constraints as Assert; + + class Transaction + { + /** + * @Assert\CardScheme(schemes = {"VISA"}, message = "Your credit card number is invalid.") + */ + protected $cardNumber; + } + .. code-block:: yaml # src/Acme/SubscriptionBundle/Resources/config/validation.yml @@ -57,21 +72,6 @@ on an object that will contain a credit card number. - .. code-block:: php-annotations - - // src/Acme/SubscriptionBundle/Entity/Transaction.php - namespace Acme\SubscriptionBundle\Entity\Transaction; - - use Symfony\Component\Validator\Constraints as Assert; - - class Transaction - { - /** - * @Assert\CardScheme(schemes = {"VISA"}, message = "Your credit card number is invalid.") - */ - protected $cardNumber; - } - .. code-block:: php // src/Acme/SubscriptionBundle/Entity/Transaction.php diff --git a/reference/constraints/Choice.rst b/reference/constraints/Choice.rst index aab73b59c44..5fa2a2d3662 100644 --- a/reference/constraints/Choice.rst +++ b/reference/constraints/Choice.rst @@ -36,16 +36,6 @@ If your valid choice list is simple, you can pass them in directly via the .. configuration-block:: - .. code-block:: yaml - - # src/Acme/BlogBundle/Resources/config/validation.yml - Acme\BlogBundle\Entity\Author: - properties: - gender: - - Choice: - choices: [male, female] - message: Choose a valid gender. - .. code-block:: php-annotations // src/Acme/BlogBundle/Entity/Author.php @@ -61,6 +51,16 @@ If your valid choice list is simple, you can pass them in directly via the protected $gender; } + .. code-block:: yaml + + # src/Acme/BlogBundle/Resources/config/validation.yml + Acme\BlogBundle\Entity\Author: + properties: + gender: + - Choice: + choices: [male, female] + message: Choose a valid gender. + .. code-block:: xml @@ -129,14 +129,6 @@ constraint. .. configuration-block:: - .. code-block:: yaml - - # src/Acme/BlogBundle/Resources/config/validation.yml - Acme\BlogBundle\Entity\Author: - properties: - gender: - - Choice: { callback: getGenders } - .. code-block:: php-annotations // src/Acme/BlogBundle/Entity/Author.php @@ -152,6 +144,14 @@ constraint. protected $gender; } + .. code-block:: yaml + + # src/Acme/BlogBundle/Resources/config/validation.yml + Acme\BlogBundle\Entity\Author: + properties: + gender: + - Choice: { callback: getGenders } + .. code-block:: xml @@ -194,14 +194,6 @@ you can pass the class name and the method as an array. .. configuration-block:: - .. code-block:: yaml - - # src/Acme/BlogBundle/Resources/config/validation.yml - Acme\BlogBundle\Entity\Author: - properties: - gender: - - Choice: { callback: [Util, getGenders] } - .. code-block:: php-annotations // src/Acme/BlogBundle/Entity/Author.php @@ -217,6 +209,14 @@ you can pass the class name and the method as an array. protected $gender; } + .. code-block:: yaml + + # src/Acme/BlogBundle/Resources/config/validation.yml + Acme\BlogBundle\Entity\Author: + properties: + gender: + - Choice: { callback: [Util, getGenders] } + .. code-block:: xml diff --git a/reference/constraints/Collection.rst b/reference/constraints/Collection.rst index 2c93325da2f..def91862c3f 100644 --- a/reference/constraints/Collection.rst +++ b/reference/constraints/Collection.rst @@ -52,22 +52,6 @@ blank but is no longer than 100 characters in length, you would do the following .. configuration-block:: - .. code-block:: yaml - - # src/Acme/BlogBundle/Resources/config/validation.yml - Acme\BlogBundle\Entity\Author: - properties: - profileData: - - Collection: - fields: - personal_email: Email - short_bio: - - NotBlank - - Length: - max: 100 - maxMessage: Your short bio is too long! - allowMissingFields: true - .. code-block:: php-annotations // src/Acme/BlogBundle/Entity/Author.php @@ -98,6 +82,22 @@ blank but is no longer than 100 characters in length, you would do the following ); } + .. code-block:: yaml + + # src/Acme/BlogBundle/Resources/config/validation.yml + Acme\BlogBundle\Entity\Author: + properties: + profileData: + - Collection: + fields: + personal_email: Email + short_bio: + - NotBlank + - Length: + max: 100 + maxMessage: Your short bio is too long! + allowMissingFields: true + .. code-block:: xml @@ -189,22 +189,6 @@ field is optional but must be a valid email if supplied, you can do the followin .. configuration-block:: - .. code-block:: yaml - - # src/Acme/BlogBundle/Resources/config/validation.yml - Acme\BlogBundle\Entity\Author: - properties: - profile_data: - - Collection: - fields: - personal_email: - - Required - - NotBlank: ~ - - Email: ~ - alternate_email: - - Optional: - - Email: ~ - .. code-block:: php-annotations // src/Acme/BlogBundle/Entity/Author.php @@ -225,6 +209,22 @@ field is optional but must be a valid email if supplied, you can do the followin protected $profileData = array('personal_email'); } + .. code-block:: yaml + + # src/Acme/BlogBundle/Resources/config/validation.yml + Acme\BlogBundle\Entity\Author: + properties: + profile_data: + - Collection: + fields: + personal_email: + - Required + - NotBlank: ~ + - Email: ~ + alternate_email: + - Optional: + - Email: ~ + .. code-block:: xml diff --git a/reference/constraints/Count.rst b/reference/constraints/Count.rst index 8a5d007ec99..0685b87bfe0 100644 --- a/reference/constraints/Count.rst +++ b/reference/constraints/Count.rst @@ -26,18 +26,6 @@ you might add the following: .. configuration-block:: - .. code-block:: yaml - - # src/Acme/EventBundle/Resources/config/validation.yml - Acme\EventBundle\Entity\Participant: - properties: - emails: - - Count: - min: 1 - max: 5 - minMessage: "You must specify at least one email" - maxMessage: "You cannot specify more than {{ limit }} emails" - .. code-block:: php-annotations // src/Acme/EventBundle/Entity/Participant.php @@ -58,6 +46,18 @@ you might add the following: protected $emails = array(); } + .. code-block:: yaml + + # src/Acme/EventBundle/Resources/config/validation.yml + Acme\EventBundle\Entity\Participant: + properties: + emails: + - Count: + min: 1 + max: 5 + minMessage: "You must specify at least one email" + maxMessage: "You cannot specify more than {{ limit }} emails" + .. code-block:: xml diff --git a/reference/constraints/Country.rst b/reference/constraints/Country.rst index f6dc5c10446..9692830ae6b 100644 --- a/reference/constraints/Country.rst +++ b/reference/constraints/Country.rst @@ -18,14 +18,6 @@ Basic Usage .. configuration-block:: - .. code-block:: yaml - - # src/Acme/UserBundle/Resources/config/validation.yml - Acme\UserBundle\Entity\User: - properties: - country: - - Country: ~ - .. code-block:: php-annotations // src/Acme/UserBundle/Entity/User.php @@ -41,6 +33,14 @@ Basic Usage protected $country; } + .. code-block:: yaml + + # src/Acme/UserBundle/Resources/config/validation.yml + Acme\UserBundle\Entity\User: + properties: + country: + - Country: ~ + .. code-block:: xml diff --git a/reference/constraints/Currency.rst b/reference/constraints/Currency.rst index 553c2be4ec1..ae5cad8cec7 100644 --- a/reference/constraints/Currency.rst +++ b/reference/constraints/Currency.rst @@ -24,14 +24,6 @@ currency, you could do the following: .. configuration-block:: - .. code-block:: yaml - - # src/Acme/EcommerceBundle/Resources/config/validation.yml - Acme\EcommerceBundle\Entity\Order: - properties: - currency: - - Currency: ~ - .. code-block:: php-annotations // src/Acme/EcommerceBundle/Entity/Order.php @@ -47,6 +39,14 @@ currency, you could do the following: protected $currency; } + .. code-block:: yaml + + # src/Acme/EcommerceBundle/Resources/config/validation.yml + Acme\EcommerceBundle\Entity\Order: + properties: + currency: + - Currency: ~ + .. code-block:: xml diff --git a/reference/constraints/Date.rst b/reference/constraints/Date.rst index 88ff0aea46c..62bc0f98a05 100644 --- a/reference/constraints/Date.rst +++ b/reference/constraints/Date.rst @@ -20,14 +20,6 @@ Basic Usage .. configuration-block:: - .. code-block:: yaml - - # src/Acme/BlogBundle/Resources/config/validation.yml - Acme\BlogBundle\Entity\Author: - properties: - birthday: - - Date: ~ - .. code-block:: php-annotations // src/Acme/BlogBundle/Entity/Author.php @@ -43,6 +35,14 @@ Basic Usage protected $birthday; } + .. code-block:: yaml + + # src/Acme/BlogBundle/Resources/config/validation.yml + Acme\BlogBundle\Entity\Author: + properties: + birthday: + - Date: ~ + .. code-block:: xml diff --git a/reference/constraints/DateTime.rst b/reference/constraints/DateTime.rst index c6897b9edf6..4060e2f0c4f 100644 --- a/reference/constraints/DateTime.rst +++ b/reference/constraints/DateTime.rst @@ -20,14 +20,6 @@ Basic Usage .. configuration-block:: - .. code-block:: yaml - - # src/Acme/BlogBundle/Resources/config/validation.yml - Acme\BlogBundle\Entity\Author: - properties: - createdAt: - - DateTime: ~ - .. code-block:: php-annotations // src/Acme/BlogBundle/Entity/Author.php @@ -43,6 +35,14 @@ Basic Usage protected $createdAt; } + .. code-block:: yaml + + # src/Acme/BlogBundle/Resources/config/validation.yml + Acme\BlogBundle\Entity\Author: + properties: + createdAt: + - DateTime: ~ + .. code-block:: xml diff --git a/reference/constraints/Email.rst b/reference/constraints/Email.rst index 85e15ec85d6..f6d35c61641 100644 --- a/reference/constraints/Email.rst +++ b/reference/constraints/Email.rst @@ -21,16 +21,6 @@ Basic Usage .. configuration-block:: - .. code-block:: yaml - - # src/Acme/BlogBundle/Resources/config/validation.yml - Acme\BlogBundle\Entity\Author: - properties: - email: - - Email: - message: The email "{{ value }}" is not a valid email. - checkMX: true - .. code-block:: php-annotations // src/Acme/BlogBundle/Entity/Author.php @@ -49,6 +39,16 @@ Basic Usage protected $email; } + .. code-block:: yaml + + # src/Acme/BlogBundle/Resources/config/validation.yml + Acme\BlogBundle\Entity\Author: + properties: + email: + - Email: + message: The email "{{ value }}" is not a valid email. + checkMX: true + .. code-block:: xml diff --git a/reference/constraints/EqualTo.rst b/reference/constraints/EqualTo.rst index c57fce55e11..e78edeb2496 100644 --- a/reference/constraints/EqualTo.rst +++ b/reference/constraints/EqualTo.rst @@ -32,15 +32,6 @@ If you want to ensure that the ``age`` of a ``Person`` class is equal to .. configuration-block:: - .. code-block:: yaml - - # src/Acme/SocialBundle/Resources/config/validation.yml - Acme\SocialBundle\Entity\Person: - properties: - age: - - EqualTo: - value: 20 - .. code-block:: php-annotations // src/Acme/SocialBundle/Entity/Person.php @@ -58,6 +49,15 @@ If you want to ensure that the ``age`` of a ``Person`` class is equal to protected $age; } + .. code-block:: yaml + + # src/Acme/SocialBundle/Resources/config/validation.yml + Acme\SocialBundle\Entity\Person: + properties: + age: + - EqualTo: + value: 20 + .. code-block:: xml diff --git a/reference/constraints/False.rst b/reference/constraints/False.rst index b3d241881e7..07fcc5ffbcc 100644 --- a/reference/constraints/False.rst +++ b/reference/constraints/False.rst @@ -39,15 +39,6 @@ method returns **false**: .. configuration-block:: - .. code-block:: yaml - - # src/Acme/BlogBundle/Resources/config/validation.yml - Acme\BlogBundle\Entity\Author - getters: - stateInvalid: - - 'False': - message: You've entered an invalid state. - .. code-block:: php-annotations // src/Acme/BlogBundle/Entity/Author.php @@ -68,6 +59,15 @@ method returns **false**: } } + .. code-block:: yaml + + # src/Acme/BlogBundle/Resources/config/validation.yml + Acme\BlogBundle\Entity\Author + getters: + stateInvalid: + - 'False': + message: You've entered an invalid state. + .. code-block:: xml diff --git a/reference/constraints/File.rst b/reference/constraints/File.rst index c062199744e..7a87bb737e9 100644 --- a/reference/constraints/File.rst +++ b/reference/constraints/File.rst @@ -68,17 +68,6 @@ below a certain file size and a valid PDF, add the following: .. configuration-block:: - .. code-block:: yaml - - # src/Acme/BlogBundle/Resources/config/validation.yml - Acme\BlogBundle\Entity\Author: - properties: - bioFile: - - File: - maxSize: 1024k - mimeTypes: [application/pdf, application/x-pdf] - mimeTypesMessage: Please upload a valid PDF - .. code-block:: php-annotations // src/Acme/BlogBundle/Entity/Author.php @@ -98,6 +87,17 @@ below a certain file size and a valid PDF, add the following: protected $bioFile; } + .. code-block:: yaml + + # src/Acme/BlogBundle/Resources/config/validation.yml + Acme\BlogBundle\Entity\Author: + properties: + bioFile: + - File: + maxSize: 1024k + mimeTypes: [application/pdf, application/x-pdf] + mimeTypesMessage: Please upload a valid PDF + .. code-block:: xml diff --git a/reference/constraints/GreaterThan.rst b/reference/constraints/GreaterThan.rst index 2d773953bcd..f553786a0ed 100644 --- a/reference/constraints/GreaterThan.rst +++ b/reference/constraints/GreaterThan.rst @@ -28,15 +28,6 @@ If you want to ensure that the ``age`` of a ``Person`` class is greater than .. configuration-block:: - .. code-block:: yaml - - # src/Acme/SocialBundle/Resources/config/validation.yml - Acme\SocialBundle\Entity\Person: - properties: - age: - - GreaterThan: - value: 18 - .. code-block:: php-annotations // src/Acme/SocialBundle/Entity/Person.php @@ -54,6 +45,15 @@ If you want to ensure that the ``age`` of a ``Person`` class is greater than protected $age; } + .. code-block:: yaml + + # src/Acme/SocialBundle/Resources/config/validation.yml + Acme\SocialBundle\Entity\Person: + properties: + age: + - GreaterThan: + value: 18 + .. code-block:: xml diff --git a/reference/constraints/GreaterThanOrEqual.rst b/reference/constraints/GreaterThanOrEqual.rst index 9d4cf37ecc5..4a10e2355eb 100644 --- a/reference/constraints/GreaterThanOrEqual.rst +++ b/reference/constraints/GreaterThanOrEqual.rst @@ -27,15 +27,6 @@ or equal to ``18``, you could do the following: .. configuration-block:: - .. code-block:: yaml - - # src/Acme/SocialBundle/Resources/config/validation.yml - Acme\SocialBundle\Entity\Person: - properties: - age: - - GreaterThanOrEqual: - value: 18 - .. code-block:: php-annotations // src/Acme/SocialBundle/Entity/Person.php @@ -53,6 +44,15 @@ or equal to ``18``, you could do the following: protected $age; } + .. code-block:: yaml + + # src/Acme/SocialBundle/Resources/config/validation.yml + Acme\SocialBundle\Entity\Person: + properties: + age: + - GreaterThanOrEqual: + value: 18 + .. code-block:: xml diff --git a/reference/constraints/Iban.rst b/reference/constraints/Iban.rst index 45a423e945c..bb60414a953 100644 --- a/reference/constraints/Iban.rst +++ b/reference/constraints/Iban.rst @@ -27,15 +27,6 @@ will contain an International Bank Account Number. .. configuration-block:: - .. code-block:: yaml - - # src/Acme/SubscriptionBundle/Resources/config/validation.yml - Acme\SubscriptionBundle\Entity\Transaction: - properties: - bankAccountNumber: - - Iban: - message: This is not a valid International Bank Account Number (IBAN). - .. code-block:: php-annotations // src/Acme/SubscriptionBundle/Entity/Transaction.php @@ -51,6 +42,15 @@ will contain an International Bank Account Number. protected $bankAccountNumber; } + .. code-block:: yaml + + # src/Acme/SubscriptionBundle/Resources/config/validation.yml + Acme\SubscriptionBundle\Entity\Transaction: + properties: + bankAccountNumber: + - Iban: + message: This is not a valid International Bank Account Number (IBAN). + .. code-block:: xml diff --git a/reference/constraints/IdenticalTo.rst b/reference/constraints/IdenticalTo.rst index 068035f31a9..0aa32d57200 100644 --- a/reference/constraints/IdenticalTo.rst +++ b/reference/constraints/IdenticalTo.rst @@ -33,15 +33,6 @@ If you want to ensure that the ``age`` of a ``Person`` class is equal to .. configuration-block:: - .. code-block:: yaml - - # src/Acme/SocialBundle/Resources/config/validation.yml - Acme\SocialBundle\Entity\Person: - properties: - age: - - IdenticalTo: - value: 20 - .. code-block:: php-annotations // src/Acme/SocialBundle/Entity/Person.php @@ -59,6 +50,15 @@ If you want to ensure that the ``age`` of a ``Person`` class is equal to protected $age; } + .. code-block:: yaml + + # src/Acme/SocialBundle/Resources/config/validation.yml + Acme\SocialBundle\Entity\Person: + properties: + age: + - IdenticalTo: + value: 20 + .. code-block:: xml diff --git a/reference/constraints/Image.rst b/reference/constraints/Image.rst index 3ba81f818fc..e2c0b55cc4c 100644 --- a/reference/constraints/Image.rst +++ b/reference/constraints/Image.rst @@ -66,18 +66,6 @@ it is between a certain size, add the following: .. configuration-block:: - .. code-block:: yaml - - # src/Acme/BlogBundle/Resources/config/validation.yml - Acme\BlogBundle\Entity\Author - properties: - headshot: - - Image: - minWidth: 200 - maxWidth: 400 - minHeight: 200 - maxHeight: 400 - .. code-block:: php-annotations // src/Acme/BlogBundle/Entity/Author.php @@ -98,6 +86,18 @@ it is between a certain size, add the following: protected $headshot; } + .. code-block:: yaml + + # src/Acme/BlogBundle/Resources/config/validation.yml + Acme\BlogBundle\Entity\Author + properties: + headshot: + - Image: + minWidth: 200 + maxWidth: 400 + minHeight: 200 + maxHeight: 400 + .. code-block:: xml diff --git a/reference/constraints/Ip.rst b/reference/constraints/Ip.rst index 0cea9668340..a07715cb2b9 100644 --- a/reference/constraints/Ip.rst +++ b/reference/constraints/Ip.rst @@ -21,14 +21,6 @@ Basic Usage .. configuration-block:: - .. code-block:: yaml - - # src/Acme/BlogBundle/Resources/config/validation.yml - Acme\BlogBundle\Entity\Author: - properties: - ipAddress: - - Ip: ~ - .. code-block:: php-annotations // src/Acme/BlogBundle/Entity/Author.php @@ -44,6 +36,14 @@ Basic Usage protected $ipAddress; } + .. code-block:: yaml + + # src/Acme/BlogBundle/Resources/config/validation.yml + Acme\BlogBundle\Entity\Author: + properties: + ipAddress: + - Ip: ~ + .. code-block:: xml diff --git a/reference/constraints/Isbn.rst b/reference/constraints/Isbn.rst index 84cb78b16e5..a69cf17ed69 100644 --- a/reference/constraints/Isbn.rst +++ b/reference/constraints/Isbn.rst @@ -29,17 +29,6 @@ on an object that will contain a ISBN number. .. configuration-block:: - .. code-block:: yaml - - # src/Acme/BookcaseBundle/Resources/config/validation.yml - Acme\BookcaseBundle\Entity\Book: - properties: - isbn: - - Isbn: - isbn10: true - isbn13: true - bothIsbnMessage: This value is neither a valid ISBN-10 nor a valid ISBN-13. - .. code-block:: php-annotations // src/Acme/BookcaseBundle/Entity/Book.php @@ -59,6 +48,17 @@ on an object that will contain a ISBN number. protected $isbn; } + .. code-block:: yaml + + # src/Acme/BookcaseBundle/Resources/config/validation.yml + Acme\BookcaseBundle\Entity\Book: + properties: + isbn: + - Isbn: + isbn10: true + isbn13: true + bothIsbnMessage: This value is neither a valid ISBN-10 nor a valid ISBN-13. + .. code-block:: xml diff --git a/reference/constraints/Issn.rst b/reference/constraints/Issn.rst index 0c200a73490..c89341d10fe 100644 --- a/reference/constraints/Issn.rst +++ b/reference/constraints/Issn.rst @@ -23,14 +23,6 @@ Basic Usage .. configuration-block:: - .. code-block:: yaml - - # src/Acme/JournalBundle/Resources/config/validation.yml - Acme\JournalBundle\Entity\Journal: - properties: - issn: - - Issn: ~ - .. code-block:: php-annotations // src/Acme/JournalBundle/Entity/Journal.php @@ -46,6 +38,14 @@ Basic Usage protected $issn; } + .. code-block:: yaml + + # src/Acme/JournalBundle/Resources/config/validation.yml + Acme\JournalBundle\Entity\Journal: + properties: + issn: + - Issn: ~ + .. code-block:: xml diff --git a/reference/constraints/Language.rst b/reference/constraints/Language.rst index 617d554a508..688ff9700e9 100644 --- a/reference/constraints/Language.rst +++ b/reference/constraints/Language.rst @@ -19,14 +19,6 @@ Basic Usage .. configuration-block:: - .. code-block:: yaml - - # src/Acme/UserBundle/Resources/config/validation.yml - Acme\UserBundle\Entity\User: - properties: - preferredLanguage: - - Language: ~ - .. code-block:: php-annotations // src/Acme/UserBundle/Entity/User.php @@ -42,6 +34,14 @@ Basic Usage protected $preferredLanguage; } + .. code-block:: yaml + + # src/Acme/UserBundle/Resources/config/validation.yml + Acme\UserBundle\Entity\User: + properties: + preferredLanguage: + - Language: ~ + .. code-block:: xml diff --git a/reference/constraints/Length.rst b/reference/constraints/Length.rst index 8fb09d362d7..84a8bf32f15 100644 --- a/reference/constraints/Length.rst +++ b/reference/constraints/Length.rst @@ -26,18 +26,6 @@ To verify that the ``firstName`` field length of a class is between "2" and .. configuration-block:: - .. code-block:: yaml - - # src/Acme/EventBundle/Resources/config/validation.yml - Acme\EventBundle\Entity\Participant: - properties: - firstName: - - Length: - min: 2 - max: 50 - minMessage: "Your first name must be at least {{ limit }} characters long" - maxMessage: "Your first name cannot be longer than {{ limit }} characters" - .. code-block:: php-annotations // src/Acme/EventBundle/Entity/Participant.php @@ -58,6 +46,18 @@ To verify that the ``firstName`` field length of a class is between "2" and protected $firstName; } + .. code-block:: yaml + + # src/Acme/EventBundle/Resources/config/validation.yml + Acme\EventBundle\Entity\Participant: + properties: + firstName: + - Length: + min: 2 + max: 50 + minMessage: "Your first name must be at least {{ limit }} characters long" + maxMessage: "Your first name cannot be longer than {{ limit }} characters" + .. code-block:: xml diff --git a/reference/constraints/LessThan.rst b/reference/constraints/LessThan.rst index ea5be3c6675..010ba49f9be 100644 --- a/reference/constraints/LessThan.rst +++ b/reference/constraints/LessThan.rst @@ -28,15 +28,6 @@ If you want to ensure that the ``age`` of a ``Person`` class is less than .. configuration-block:: - .. code-block:: yaml - - # src/Acme/SocialBundle/Resources/config/validation.yml - Acme\SocialBundle\Entity\Person: - properties: - age: - - LessThan: - value: 80 - .. code-block:: php-annotations // src/Acme/SocialBundle/Entity/Person.php @@ -54,6 +45,15 @@ If you want to ensure that the ``age`` of a ``Person`` class is less than protected $age; } + .. code-block:: yaml + + # src/Acme/SocialBundle/Resources/config/validation.yml + Acme\SocialBundle\Entity\Person: + properties: + age: + - LessThan: + value: 80 + .. code-block:: xml diff --git a/reference/constraints/LessThanOrEqual.rst b/reference/constraints/LessThanOrEqual.rst index a936ee76ba8..363742c95c5 100644 --- a/reference/constraints/LessThanOrEqual.rst +++ b/reference/constraints/LessThanOrEqual.rst @@ -27,15 +27,6 @@ equal to ``80``, you could do the following: .. configuration-block:: - .. code-block:: yaml - - # src/Acme/SocialBundle/Resources/config/validation.yml - Acme\SocialBundle\Entity\Person: - properties: - age: - - LessThanOrEqual: - value: 80 - .. code-block:: php-annotations // src/Acme/SocialBundle/Entity/Person.php @@ -53,6 +44,15 @@ equal to ``80``, you could do the following: protected $age; } + .. code-block:: yaml + + # src/Acme/SocialBundle/Resources/config/validation.yml + Acme\SocialBundle\Entity\Person: + properties: + age: + - LessThanOrEqual: + value: 80 + .. code-block:: xml diff --git a/reference/constraints/Locale.rst b/reference/constraints/Locale.rst index cf411c11ecb..8a87d7bb461 100644 --- a/reference/constraints/Locale.rst +++ b/reference/constraints/Locale.rst @@ -22,14 +22,6 @@ Basic Usage .. configuration-block:: - .. code-block:: yaml - - # src/Acme/UserBundle/Resources/config/validation.yml - Acme\UserBundle\Entity\User: - properties: - locale: - - Locale: ~ - .. code-block:: php-annotations // src/Acme/UserBundle/Entity/User.php @@ -45,6 +37,14 @@ Basic Usage protected $locale; } + .. code-block:: yaml + + # src/Acme/UserBundle/Resources/config/validation.yml + Acme\UserBundle\Entity\User: + properties: + locale: + - Locale: ~ + .. code-block:: xml diff --git a/reference/constraints/Luhn.rst b/reference/constraints/Luhn.rst index 97d1d27d743..637f925914f 100644 --- a/reference/constraints/Luhn.rst +++ b/reference/constraints/Luhn.rst @@ -26,15 +26,6 @@ will contain a credit card number. .. configuration-block:: - .. code-block:: yaml - - # src/Acme/SubscriptionBundle/Resources/config/validation.yml - Acme\SubscriptionBundle\Entity\Transaction: - properties: - cardNumber: - - Luhn: - message: Please check your credit card number. - .. code-block:: php-annotations // src/Acme/SubscriptionBundle/Entity/Transaction.php @@ -50,6 +41,15 @@ will contain a credit card number. protected $cardNumber; } + .. code-block:: yaml + + # src/Acme/SubscriptionBundle/Resources/config/validation.yml + Acme\SubscriptionBundle\Entity\Transaction: + properties: + cardNumber: + - Luhn: + message: Please check your credit card number. + .. code-block:: xml diff --git a/reference/constraints/NotBlank.rst b/reference/constraints/NotBlank.rst index 8de6034b48c..1dbfa60d853 100644 --- a/reference/constraints/NotBlank.rst +++ b/reference/constraints/NotBlank.rst @@ -23,14 +23,6 @@ were not blank, you could do the following: .. configuration-block:: - .. code-block:: yaml - - # src/Acme/BlogBundle/Resources/config/validation.yml - Acme\BlogBundle\Entity\Author: - properties: - firstName: - - NotBlank: ~ - .. code-block:: php-annotations // src/Acme/BlogBundle/Entity/Author.php @@ -46,6 +38,14 @@ were not blank, you could do the following: protected $firstName; } + .. code-block:: yaml + + # src/Acme/BlogBundle/Resources/config/validation.yml + Acme\BlogBundle\Entity\Author: + properties: + firstName: + - NotBlank: ~ + .. code-block:: xml diff --git a/reference/constraints/NotEqualTo.rst b/reference/constraints/NotEqualTo.rst index 1ea36a08994..211b88df865 100644 --- a/reference/constraints/NotEqualTo.rst +++ b/reference/constraints/NotEqualTo.rst @@ -33,15 +33,6 @@ If you want to ensure that the ``age`` of a ``Person`` class is not equal to .. configuration-block:: - .. code-block:: yaml - - # src/Acme/SocialBundle/Resources/config/validation.yml - Acme\SocialBundle\Entity\Person: - properties: - age: - - NotEqualTo: - value: 15 - .. code-block:: php-annotations // src/Acme/SocialBundle/Entity/Person.php @@ -59,6 +50,15 @@ If you want to ensure that the ``age`` of a ``Person`` class is not equal to protected $age; } + .. code-block:: yaml + + # src/Acme/SocialBundle/Resources/config/validation.yml + Acme\SocialBundle\Entity\Person: + properties: + age: + - NotEqualTo: + value: 15 + .. code-block:: xml diff --git a/reference/constraints/NotIdenticalTo.rst b/reference/constraints/NotIdenticalTo.rst index 63e6b0462dd..7633e1fec61 100644 --- a/reference/constraints/NotIdenticalTo.rst +++ b/reference/constraints/NotIdenticalTo.rst @@ -33,15 +33,6 @@ If you want to ensure that the ``age`` of a ``Person`` class is *not* equal to .. configuration-block:: - .. code-block:: yaml - - # src/Acme/SocialBundle/Resources/config/validation.yml - Acme\SocialBundle\Entity\Person: - properties: - age: - - NotIdenticalTo: - value: 15 - .. code-block:: php-annotations // src/Acme/SocialBundle/Entity/Person.php @@ -59,6 +50,15 @@ If you want to ensure that the ``age`` of a ``Person`` class is *not* equal to protected $age; } + .. code-block:: yaml + + # src/Acme/SocialBundle/Resources/config/validation.yml + Acme\SocialBundle\Entity\Person: + properties: + age: + - NotIdenticalTo: + value: 15 + .. code-block:: xml diff --git a/reference/constraints/NotNull.rst b/reference/constraints/NotNull.rst index 668aa5dfd1b..333481f49e4 100644 --- a/reference/constraints/NotNull.rst +++ b/reference/constraints/NotNull.rst @@ -23,14 +23,6 @@ were not strictly equal to ``null``, you would: .. configuration-block:: - .. code-block:: yaml - - # src/Acme/BlogBundle/Resources/config/validation.yml - Acme\BlogBundle\Entity\Author: - properties: - firstName: - - NotNull: ~ - .. code-block:: php-annotations // src/Acme/BlogBundle/Entity/Author.php @@ -46,6 +38,14 @@ were not strictly equal to ``null``, you would: protected $firstName; } + .. code-block:: yaml + + # src/Acme/BlogBundle/Resources/config/validation.yml + Acme\BlogBundle\Entity\Author: + properties: + firstName: + - NotNull: ~ + .. code-block:: xml diff --git a/reference/constraints/Null.rst b/reference/constraints/Null.rst index 38baf3d1929..27a7b5861dc 100644 --- a/reference/constraints/Null.rst +++ b/reference/constraints/Null.rst @@ -23,14 +23,6 @@ of an ``Author`` class exactly equal to ``null``, you could do the following: .. configuration-block:: - .. code-block:: yaml - - # src/Acme/BlogBundle/Resources/config/validation.yml - Acme\BlogBundle\Entity\Author: - properties: - firstName: - - 'Null': ~ - .. code-block:: php-annotations // src/Acme/BlogBundle/Entity/Author.php @@ -46,6 +38,14 @@ of an ``Author`` class exactly equal to ``null``, you could do the following: protected $firstName; } + .. code-block:: yaml + + # src/Acme/BlogBundle/Resources/config/validation.yml + Acme\BlogBundle\Entity\Author: + properties: + firstName: + - 'Null': ~ + .. code-block:: xml diff --git a/reference/constraints/Range.rst b/reference/constraints/Range.rst index 03781307ff2..92cefbd80b6 100644 --- a/reference/constraints/Range.rst +++ b/reference/constraints/Range.rst @@ -25,18 +25,6 @@ the following: .. configuration-block:: - .. code-block:: yaml - - # src/Acme/EventBundle/Resources/config/validation.yml - Acme\EventBundle\Entity\Participant: - properties: - height: - - Range: - min: 120 - max: 180 - minMessage: You must be at least {{ limit }}cm tall to enter - maxMessage: You cannot be taller than {{ limit }}cm to enter - .. code-block:: php-annotations // src/Acme/EventBundle/Entity/Participant.php @@ -57,6 +45,18 @@ the following: protected $height; } + .. code-block:: yaml + + # src/Acme/EventBundle/Resources/config/validation.yml + Acme\EventBundle\Entity\Participant: + properties: + height: + - Range: + min: 120 + max: 180 + minMessage: You must be at least {{ limit }}cm tall to enter + maxMessage: You cannot be taller than {{ limit }}cm to enter + .. code-block:: xml diff --git a/reference/constraints/Regex.rst b/reference/constraints/Regex.rst index ab6e98134d4..05f3e130b8b 100644 --- a/reference/constraints/Regex.rst +++ b/reference/constraints/Regex.rst @@ -26,14 +26,6 @@ characters at the beginning of your string: .. configuration-block:: - .. code-block:: yaml - - # src/Acme/BlogBundle/Resources/config/validation.yml - Acme\BlogBundle\Entity\Author: - properties: - description: - - Regex: '/^\w+/' - .. code-block:: php-annotations // src/Acme/BlogBundle/Entity/Author.php @@ -49,6 +41,14 @@ characters at the beginning of your string: protected $description; } + .. code-block:: yaml + + # src/Acme/BlogBundle/Resources/config/validation.yml + Acme\BlogBundle\Entity\Author: + properties: + description: + - Regex: '/^\w+/' + .. code-block:: xml @@ -91,17 +91,6 @@ message: .. configuration-block:: - .. code-block:: yaml - - # src/Acme/BlogBundle/Resources/config/validation.yml - Acme\BlogBundle\Entity\Author: - properties: - firstName: - - Regex: - pattern: '/\d/' - match: false - message: Your name cannot contain a number - .. code-block:: php-annotations // src/Acme/BlogBundle/Entity/Author.php @@ -121,6 +110,17 @@ message: protected $firstName; } + .. code-block:: yaml + + # src/Acme/BlogBundle/Resources/config/validation.yml + Acme\BlogBundle\Entity\Author: + properties: + firstName: + - Regex: + pattern: '/\d/' + match: false + message: Your name cannot contain a number + .. code-block:: xml @@ -194,16 +194,6 @@ to specify the HTML5 compatible pattern in the ``htmlPattern`` option: .. configuration-block:: - .. code-block:: yaml - - # src/Acme/BlogBundle/Resources/config/validation.yml - Acme\BlogBundle\Entity\Author: - properties: - name: - - Regex: - pattern: "/^[a-z]+$/i" - htmlPattern: "^[a-zA-Z]+$" - .. code-block:: php-annotations // src/Acme/BlogBundle/Entity/Author.php @@ -222,6 +212,16 @@ to specify the HTML5 compatible pattern in the ``htmlPattern`` option: protected $name; } + .. code-block:: yaml + + # src/Acme/BlogBundle/Resources/config/validation.yml + Acme\BlogBundle\Entity\Author: + properties: + name: + - Regex: + pattern: "/^[a-z]+$/i" + htmlPattern: "^[a-zA-Z]+$" + .. code-block:: xml diff --git a/reference/constraints/Time.rst b/reference/constraints/Time.rst index 251bb007eab..f95125db402 100644 --- a/reference/constraints/Time.rst +++ b/reference/constraints/Time.rst @@ -23,14 +23,6 @@ of the day when the event starts: .. configuration-block:: - .. code-block:: yaml - - # src/Acme/EventBundle/Resources/config/validation.yml - Acme\EventBundle\Entity\Event: - properties: - startsAt: - - Time: ~ - .. code-block:: php-annotations // src/Acme/EventBundle/Entity/Event.php @@ -46,6 +38,14 @@ of the day when the event starts: protected $startsAt; } + .. code-block:: yaml + + # src/Acme/EventBundle/Resources/config/validation.yml + Acme\EventBundle\Entity\Event: + properties: + startsAt: + - Time: ~ + .. code-block:: xml diff --git a/reference/constraints/True.rst b/reference/constraints/True.rst index 8edef81ad93..f81cbec1073 100644 --- a/reference/constraints/True.rst +++ b/reference/constraints/True.rst @@ -44,15 +44,6 @@ Then you can constrain this method with ``True``. .. configuration-block:: - .. code-block:: yaml - - # src/Acme/BlogBundle/Resources/config/validation.yml - Acme\BlogBundle\Entity\Author: - getters: - tokenValid: - - 'True': - message: The token is invalid. - .. code-block:: php-annotations // src/Acme/BlogBundle/Entity/Author.php @@ -73,6 +64,15 @@ Then you can constrain this method with ``True``. } } + .. code-block:: yaml + + # src/Acme/BlogBundle/Resources/config/validation.yml + Acme\BlogBundle\Entity\Author: + getters: + tokenValid: + - 'True': + message: The token is invalid. + .. code-block:: xml diff --git a/reference/constraints/Type.rst b/reference/constraints/Type.rst index 629ca6a9431..b9323e38a93 100644 --- a/reference/constraints/Type.rst +++ b/reference/constraints/Type.rst @@ -21,16 +21,6 @@ Basic Usage .. configuration-block:: - .. code-block:: yaml - - # src/Acme/BlogBundle/Resources/config/validation.yml - Acme\BlogBundle\Entity\Author: - properties: - age: - - Type: - type: integer - message: The value {{ value }} is not a valid {{ type }}. - .. code-block:: php-annotations // src/Acme/BlogBundle/Entity/Author.php @@ -46,6 +36,16 @@ Basic Usage protected $age; } + .. code-block:: yaml + + # src/Acme/BlogBundle/Resources/config/validation.yml + Acme\BlogBundle\Entity\Author: + properties: + age: + - Type: + type: integer + message: The value {{ value }} is not a valid {{ type }}. + .. code-block:: xml diff --git a/reference/constraints/UniqueEntity.rst b/reference/constraints/UniqueEntity.rst index c2dd5e0f439..ab2c5f8c85c 100644 --- a/reference/constraints/UniqueEntity.rst +++ b/reference/constraints/UniqueEntity.rst @@ -30,16 +30,6 @@ table: .. configuration-block:: - .. code-block:: yaml - - # src/Acme/UserBundle/Resources/config/validation.yml - Acme\UserBundle\Entity\Author: - constraints: - - Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity: email - properties: - email: - - Email: ~ - .. code-block:: php-annotations // Acme/UserBundle/Entity/Author.php @@ -68,6 +58,16 @@ table: // ... } + .. code-block:: yaml + + # src/Acme/UserBundle/Resources/config/validation.yml + Acme\UserBundle\Entity\Author: + constraints: + - Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity: email + properties: + email: + - Email: ~ + .. code-block:: xml @@ -169,16 +169,6 @@ Consider this example: .. configuration-block:: - .. code-block:: yaml - - # src/Acme/AdministrationBundle/Resources/config/validation.yml - Acme\AdministrationBundle\Entity\Service: - constraints: - - Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity: - fields: [host, port] - errorPath: port - message: 'This port is already in use on that host.' - .. code-block:: php-annotations // src/Acme/AdministrationBundle/Entity/Service.php @@ -208,6 +198,16 @@ Consider this example: public $port; } + .. code-block:: yaml + + # src/Acme/AdministrationBundle/Resources/config/validation.yml + Acme\AdministrationBundle\Entity\Service: + constraints: + - Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity: + fields: [host, port] + errorPath: port + message: 'This port is already in use on that host.' + .. code-block:: xml diff --git a/reference/constraints/Url.rst b/reference/constraints/Url.rst index 42ea1f1da2c..bd9945346be 100644 --- a/reference/constraints/Url.rst +++ b/reference/constraints/Url.rst @@ -19,14 +19,6 @@ Basic Usage .. configuration-block:: - .. code-block:: yaml - - # src/Acme/BlogBundle/Resources/config/validation.yml - Acme\BlogBundle\Entity\Author: - properties: - bioUrl: - - Url: ~ - .. code-block:: php-annotations // src/Acme/BlogBundle/Entity/Author.php @@ -42,6 +34,14 @@ Basic Usage protected $bioUrl; } + .. code-block:: yaml + + # src/Acme/BlogBundle/Resources/config/validation.yml + Acme\BlogBundle\Entity\Author: + properties: + bioUrl: + - Url: ~ + .. code-block:: xml diff --git a/reference/constraints/UserPassword.rst b/reference/constraints/UserPassword.rst index 84988594242..75a9cc11b22 100644 --- a/reference/constraints/UserPassword.rst +++ b/reference/constraints/UserPassword.rst @@ -39,15 +39,6 @@ password: .. configuration-block:: - .. code-block:: yaml - - # src/Acme/UserBundle/Resources/config/validation.yml - Acme\UserBundle\Form\Model\ChangePassword: - properties: - oldPassword: - - Symfony\Component\Security\Core\Validator\Constraints\UserPassword: - message: "Wrong value for your current password" - .. code-block:: php-annotations // src/Acme/UserBundle/Form/Model/ChangePassword.php @@ -65,6 +56,15 @@ password: protected $oldPassword; } + .. code-block:: yaml + + # src/Acme/UserBundle/Resources/config/validation.yml + Acme\UserBundle\Form\Model\ChangePassword: + properties: + oldPassword: + - Symfony\Component\Security\Core\Validator\Constraints\UserPassword: + message: "Wrong value for your current password" + .. code-block:: xml diff --git a/reference/constraints/Valid.rst b/reference/constraints/Valid.rst index 629f5a2d6cb..92c0421c03d 100644 --- a/reference/constraints/Valid.rst +++ b/reference/constraints/Valid.rst @@ -48,27 +48,6 @@ an ``Address`` instance in the ``$address`` property. .. configuration-block:: - .. code-block:: yaml - - # src/Acme/HelloBundle/Resources/config/validation.yml - Acme\HelloBundle\Entity\Address: - properties: - street: - - NotBlank: ~ - zipCode: - - NotBlank: ~ - - Length: - max: 5 - - Acme\HelloBundle\Entity\Author: - properties: - firstName: - - NotBlank: ~ - - Length: - min: 4 - lastName: - - NotBlank: ~ - .. code-block:: php-annotations // src/Acme/HelloBundle/Entity/Address.php @@ -111,6 +90,27 @@ an ``Address`` instance in the ``$address`` property. protected $address; } + .. code-block:: yaml + + # src/Acme/HelloBundle/Resources/config/validation.yml + Acme\HelloBundle\Entity\Address: + properties: + street: + - NotBlank: ~ + zipCode: + - NotBlank: ~ + - Length: + max: 5 + + Acme\HelloBundle\Entity\Author: + properties: + firstName: + - NotBlank: ~ + - Length: + min: 4 + lastName: + - NotBlank: ~ + .. code-block:: xml @@ -191,14 +191,6 @@ property. .. configuration-block:: - .. code-block:: yaml - - # src/Acme/HelloBundle/Resources/config/validation.yml - Acme\HelloBundle\Entity\Author: - properties: - address: - - Valid: ~ - .. code-block:: php-annotations // src/Acme/HelloBundle/Entity/Author.php @@ -214,6 +206,14 @@ property. protected $address; } + .. code-block:: yaml + + # src/Acme/HelloBundle/Resources/config/validation.yml + Acme\HelloBundle\Entity\Author: + properties: + address: + - Valid: ~ + .. code-block:: xml