Skip to content

Commit e634bd5

Browse files
authored
Merge pull request #7515 from kenjis/docs-validation-data-array
docs: add warning on Validation $data array
2 parents 335ab86 + 0410b82 commit e634bd5

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

user_guide_src/source/libraries/validation.rst

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -690,14 +690,23 @@ Your new custom rule could now be used just like any other rule:
690690
Allowing Parameters
691691
-------------------
692692

693-
If your method needs to work with parameters, the function will need a minimum of three parameters: the value to validate,
694-
the parameter string, and an array with all of the data that was submitted the form. The ``$data`` array is especially handy
693+
If your method needs to work with parameters, the function will need a minimum of three parameters:
694+
695+
1. the value to validate (``$value``)
696+
2. the parameter string (``$params``)
697+
3. an array with all of the data that was submitted the form (``$data``)
698+
4. (optional) a custom error string (``&$error``), just as described above.
699+
700+
.. warning:: The field values in ``$data`` are unvalidated (or may be invalid).
701+
Using unvalidated input data is a source of vulnerability. You must
702+
perform the necessary validation within your custom rules before using the
703+
data in ``$data``.
704+
705+
The ``$data`` array is especially handy
695706
for rules like ``required_with`` that needs to check the value of another submitted field to base its result on:
696707

697708
.. literalinclude:: validation/037.php
698709

699-
Custom errors can be returned as the fourth parameter ``&$error``, just as described above.
700-
701710
.. _validation-using-closure-rule:
702711

703712
Using Closure Rule

0 commit comments

Comments
 (0)