Skip to content

Commit 7bcb891

Browse files
committed
minor #11006 Replaces ProtocolClassValidator for the second example (krisdante)
This PR was submitted for the 4.2 branch but it was merged into the 3.4 branch instead (closes #11006). Discussion ---------- Replaces ProtocolClassValidator for the second example Examples for Class Constraint Validator use ContainsAlphanumeric that was added as property validator. It will not work for a class. The intention of the second example seems to be the usage of ProtocolClassValidator introduced in this section (chapter). <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/roadmap for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `master` for features of unreleased versions). --> Commits ------- 42007cb Replaces ProtocolClassValidator for the second example
2 parents 6bea43f + 42007cb commit 7bcb891

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

validation/custom_constraint.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ The validator class is also simple, and only has one required method ``validate(
6868
if (!$constraint instanceof ContainsAlphanumeric) {
6969
throw new UnexpectedTypeException($constraint, ContainsAlphanumeric::class);
7070
}
71-
71+
7272
// custom constraints should ignore null and empty values to allow
7373
// other constraints (NotBlank, NotNull, etc.) take care of that
7474
if (null === $value || '' === $value) {
@@ -214,7 +214,7 @@ not to the property:
214214
.. code-block:: php-annotations
215215
216216
/**
217-
* @AcmeAssert\ContainsAlphanumeric
217+
* @AcmeAssert\ProtocolClassValidator
218218
*/
219219
class AcmeEntity
220220
{
@@ -226,11 +226,11 @@ not to the property:
226226
# src/AppBundle/Resources/config/validation.yml
227227
AppBundle\Entity\AcmeEntity:
228228
constraints:
229-
- AppBundle\Validator\Constraints\ContainsAlphanumeric: ~
229+
- AppBundle\Validator\Constraints\ProtocolClassValidator: ~
230230
231231
.. code-block:: xml
232232
233233
<!-- src/AppBundle/Resources/config/validation.xml -->
234234
<class name="AppBundle\Entity\AcmeEntity">
235-
<constraint name="AppBundle\Validator\Constraints\ContainsAlphanumeric" />
235+
<constraint name="AppBundle\Validator\Constraints\ProtocolClassValidator" />
236236
</class>

0 commit comments

Comments
 (0)