@@ -11,6 +11,7 @@ Aplus Framework MVC (Model-View-Controller) Library.
11
11
- `Services `_
12
12
- `Models `_
13
13
- `Entities `_
14
+ - `Validator `_
14
15
- `Views `_
15
16
- `Controllers `_
16
17
- `Conclusion `_
@@ -1157,7 +1158,7 @@ Validation Config Options
1157
1158
validators
1158
1159
""""""""""
1159
1160
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
1161
1162
mvc package and the FilesValidator from the Validation package.
1162
1163
1163
1164
language_instance
@@ -1971,6 +1972,59 @@ And then the JSON object:
1971
1972
1972
1973
Note that the ``url `` and ``createdAt `` property objects have been serialized.
1973
1974
1975
+ Validator
1976
+ ---------
1977
+
1978
+ The **Framework\M VC\V alidator ** 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
+
1974
2028
Views
1975
2029
-----
1976
2030
0 commit comments