Skip to content

Commit

Permalink
Add user guide content to existMany rule
Browse files Browse the repository at this point in the history
  • Loading branch information
natanfelles committed May 26, 2023
1 parent 2302691 commit d2e2c29
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions guide/index.rst
Expand Up @@ -2058,6 +2058,7 @@ The following rules can be used alongside the
`default validation rules <https://docs.aplus-framework.com/guides/libraries/validation/index.html#available-rules>`_:

- `exist`_
- `existMany`_
- `unique`_

exist
Expand All @@ -2077,6 +2078,40 @@ a dot. If the column is not defined, the field name will be used as the column n

``$connection`` is the name of the database connection. The default is ``default``.

existMany
#########

Requires that many values exists in the database.

.. code-block:: php
existMany:$tableColumn
existMany:$tableColumn,$connection
This rule is similar to `exist`_. Except it is able to check if many values are
present in a database table.

It can validate many values from a ``select`` HTML element:

.. code-block:: html

<select name="fruits[]" multiple>
<option value="1">Apple</option>
<option value="2">Orange</option>
<option value="3">Pear</option>
<option value="5">Banana</option>
<option value="9">Strawberry</option>
</select>

The following example will validate if the ids sent in the ``fruits`` field are
present in the ``Fruits`` table:

.. code-block::
existMany:Fruits.id
If any value does not exist, validation will fail.

unique
######

Expand Down

0 comments on commit d2e2c29

Please sign in to comment.