Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions en/orm/validation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ Association Count Rules
If you need to validate that a property or association contains the correct
number of values, you can use the ``validCount()`` rule::

// In the ArticleTable.php file
// No more than 5 tags on an article.
$rules->add($rules->validCount('tags', 5, '<=', 'You can only have 5 tags'));

Expand All @@ -419,6 +420,7 @@ comparison operator to use. ``==``, ``>=``, ``<=``, ``>``, ``<``, and ``!=``
are the accepted operators. To ensure a property's count is within a range, use
two rules::

// In the ArticleTable.php file
// 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'));
Expand Down