Skip to content

Commit

Permalink
Merge pull request #5137 from chinpei215/3.0-fix-three-rules
Browse files Browse the repository at this point in the history
Separate a code example of validCount rule
  • Loading branch information
markstory committed Jul 31, 2017
2 parents a409a3a + 9c3d273 commit 297d3cd
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions en/orm/validation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -444,13 +444,11 @@ two rules::
// Between 3 and 5 tags
$rules->add($rules->validCount('tags', 3, '>=', 'You must have at least 3 tags'));
$rules->add($rules->validCount('tags', 5, '<=', 'You must have at most 5 tags'));
$rules->add($rules->validCount('subscription', 0, '==', 'You may not have a subscription'));

.. note::
Note that ``validCount`` returns ``false`` if the property is not countable or does not exist::

``validCount`` returns ``false`` if the property is not countable or does not exist.
E.g. comparing via ``<``, ``<=`` or against ``0`` will return ``false``,
if you do not supply at least an empty list of - say - subscriptions.
// The save operation will fail if tags is null.
$rules->add($rules->validCount('tags', 0, '<=', 'You must not have any tags'));

.. versionadded:: 3.3.0
The ``validCount()`` method was added in 3.3.0.
Expand Down

0 comments on commit 297d3cd

Please sign in to comment.