-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[Validation] Add "hasser" support #3418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -583,8 +583,11 @@ Getters | |
|
||
Constraints can also be applied to the return value of a method. Symfony2 | ||
allows you to add a constraint to any public method whose name starts with | ||
"get" or "is". In this guide, both of these types of methods are referred | ||
to as "getters". | ||
"get", "is" or "has". In this guide, these types of methods are referred to | ||
as "getters". | ||
|
||
.. versionadded:: 2.5 | ||
Support for methods starting with ``has`` is new in Symfony 2.5. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. was introduced in Symfony 2.5. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it makes sense to also fix the wording in 2.3 and 2.4, or is it a new convention? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's a new convention and as the versionadded directives are removed quite quickly, we decided not to invest time in updating the others. We can better document the missing things! 👏 |
||
|
||
The benefit of this technique is that it allows you to validate your object | ||
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:: | |
.. note:: | ||
|
||
The keen-eyed among you will have noticed that the prefix of the getter | ||
("get" or "is") is omitted in the mapping. This allows you to move the | ||
constraint to a property with the same name later (or vice versa) without | ||
changing your validation logic. | ||
("get", "is" or "has") is omitted in the mapping. This allows you to move | ||
the constraint to a property with the same name later (or vice versa) | ||
without changing your validation logic. | ||
|
||
.. _validation-class-target: | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need a
versionadded
directive for the "hasser" supportThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added this yesterday, see commit below.