Skip to content

Commit c4aaf1c

Browse files
committed
Add Validator info in the user guide
1 parent 583d909 commit c4aaf1c

File tree

1 file changed

+55
-1
lines changed

1 file changed

+55
-1
lines changed

guide/index.rst

+55-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Aplus Framework MVC (Model-View-Controller) Library.
1111
- `Services`_
1212
- `Models`_
1313
- `Entities`_
14+
- `Validator`_
1415
- `Views`_
1516
- `Controllers`_
1617
- `Conclusion`_
@@ -1157,7 +1158,7 @@ Validation Config Options
11571158
validators
11581159
""""""""""
11591160

1160-
Sets an array of Validators. The default is an array with the Validator from the
1161+
Sets an array of Validators. The default is an array with the `Validator`_ from the
11611162
mvc package and the FilesValidator from the Validation package.
11621163

11631164
language_instance
@@ -1971,6 +1972,59 @@ And then the JSON object:
19711972
19721973
Note that the ``url`` and ``createdAt`` property objects have been serialized.
19731974

1975+
Validator
1976+
---------
1977+
1978+
The **Framework\MVC\Validator** class has additional rules that work, for example,
1979+
using database connections.
1980+
1981+
The following rules can be used alongside the
1982+
`default validation rules <https://docs.aplus-framework.com/guides/libraries/validation/index.html#available-rules>`_:
1983+
1984+
- `exist`_
1985+
- `unique`_
1986+
1987+
exist
1988+
#####
1989+
1990+
Requires that a value exists in the database.
1991+
1992+
.. code-block:: php
1993+
1994+
exist:$tableColumn
1995+
exist:$tableColumn,$connection
1996+
1997+
The rule has two parameters: ``$tableColumn`` and ``$connection``.
1998+
1999+
``$tableColumn`` is the table name and, optionally, the column name separated by
2000+
a dot. If the column is not defined, the field name will be used as the column name.
2001+
2002+
``$connection`` is the name of the database connection. The default is ``default``.
2003+
2004+
unique
2005+
######
2006+
2007+
Requires that a value is not registered in the database.
2008+
2009+
.. code-block:: php
2010+
2011+
unique:$tableColumn
2012+
unique:$tableColumn,$ignoreColumn,$ignoreValue
2013+
unique:$tableColumn,$ignoreColumn,$ignoreValue,$connection
2014+
2015+
The rule has four parameters: ``$tableColumn``, ``$ignoreColumn``,
2016+
``$ignoreValue`` and ``$connection``.
2017+
2018+
``$tableColumn`` is the table name and, optionally, the column name separated by
2019+
a dot. If the column is not defined, the field name will be used as the column name.
2020+
2021+
``$ignoreColumn`` is the name of the column to ignore if the value is already
2022+
registered. Usually when updating data.
2023+
2024+
``$ignoreValue`` is the value to be ignored in the ``$ignoreColumn``.
2025+
2026+
``$connection`` is the name of the database connection. The default is ``default``.
2027+
19742028
Views
19752029
-----
19762030

0 commit comments

Comments
 (0)