Skip to content

Commit

Permalink
feature #3418 [Validation] Add "hasser" support (bicpi)
Browse files Browse the repository at this point in the history
This PR was merged into the master branch.

Discussion
----------

[Validation] Add "hasser" support

| Q             | A
| ------------- | ---
| Doc fix?      | no
| New docs?     | yes (symfony/symfony#9097)
| Applies to    | master
| Fixed tickets | -

Commits
-------

b9f8b8d fix "versionadded" wording
bb9004e Add "versionadded" directive for 2.5
bfe3a20 [Validation] Add "hasser" support
  • Loading branch information
weaverryan committed Mar 26, 2014
2 parents cad38ae + b9f8b8d commit d7027c0
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions book/validation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`` was introduced in Symfony 2.5.

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
Expand Down Expand Up @@ -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:

Expand Down

0 comments on commit d7027c0

Please sign in to comment.