File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
Filter options
Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
Original file line number Diff line number Diff line change @@ -583,8 +583,11 @@ Getters
583
583
584
584
Constraints can also be applied to the return value of a method. Symfony2
585
585
allows you to add a constraint to any public method whose name starts with
586
- "get" or "is". In this guide, both of these types of methods are referred
587
- to as "getters".
586
+ "get", "is" or "has". In this guide, these types of methods are referred to
587
+ as "getters".
588
+
589
+ .. versionadded :: 2.5
590
+ Support for methods starting with ``has `` was introduced in Symfony 2.5.
588
591
589
592
The benefit of this technique is that it allows you to validate your object
590
593
dynamically. For example, suppose you want to make sure that a password field
@@ -665,9 +668,9 @@ Now, create the ``isPasswordLegal()`` method, and include the logic you need::
665
668
.. note ::
666
669
667
670
The keen-eyed among you will have noticed that the prefix of the getter
668
- ("get" or "is ") is omitted in the mapping. This allows you to move the
669
- constraint to a property with the same name later (or vice versa) without
670
- changing your validation logic.
671
+ ("get", "is" or "has ") is omitted in the mapping. This allows you to move
672
+ the constraint to a property with the same name later (or vice versa)
673
+ without changing your validation logic.
671
674
672
675
.. _validation-class-target :
673
676
You can’t perform that action at this time.
0 commit comments