Skip to content

Commit fe5037d

Browse files
authored
Merge pull request #5233 from kenjis/fix-docs-validation
docs: improve validation.rst
2 parents a9d72a7 + 09612db commit fe5037d

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

user_guide_src/source/libraries/validation.rst

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ On the receiving end, the script must:
3333
be someone else's existing username, or perhaps even a reserved word.
3434
Etc.
3535
#. Sanitize the data for security.
36-
#. Pre-format the data if needed (Does the data need to be trimmed? HTML
37-
encoded? Etc.)
36+
#. Pre-format the data if needed.
3837
#. Prep the data for insertion in the database.
3938

4039
Although there is nothing terribly complex about the above process, it
@@ -233,7 +232,7 @@ that should be applied::
233232
$validation->setRule('username', 'Username', 'required');
234233

235234
The **field name** must match the key of any data array that is sent in. If
236-
the data is taken directly from $_POST, then it must be an exact match for
235+
the data is taken directly from ``$_POST``, then it must be an exact match for
237236
the form input name.
238237

239238
setRules()
@@ -440,7 +439,7 @@ Validation Placeholders
440439

441440
The Validation class provides a simple method to replace parts of your rules based on data that's being passed into it. This
442441
sounds fairly obscure but can be especially handy with the ``is_unique`` validation rule. Placeholders are simply
443-
the name of the field (or array key) that was passed in as $data surrounded by curly brackets. It will be
442+
the name of the field (or array key) that was passed in as ``$data`` surrounded by curly brackets. It will be
444443
replaced by the **value** of the matched incoming field. An example should clarify this::
445444

446445
$validation->setRules([
@@ -687,7 +686,7 @@ a boolean true or false value signifying true if it passed the test or false if
687686
}
688687

689688
By default, the system will look within ``CodeIgniter\Language\en\Validation.php`` for the language strings used
690-
within errors. In custom rules, you may provide error messages by accepting a $error variable by reference in the
689+
within errors. In custom rules, you may provide error messages by accepting a ``$error`` variable by reference in the
691690
second parameter::
692691

693692
public function even(string $str, string &$error = null): bool
@@ -711,7 +710,7 @@ Allowing Parameters
711710
===================
712711

713712
If your method needs to work with parameters, the function will need a minimum of three parameters: the string to validate,
714-
the parameter string, and an array with all of the data that was submitted the form. The $data array is especially handy
713+
the parameter string, and an array with all of the data that was submitted the form. The ``$data`` array is especially handy
715714
for rules like ``require_with`` that needs to check the value of another submitted field to base its result on::
716715

717716
public function required_with($str, string $fields, array $data): bool
@@ -929,6 +928,6 @@ is_image Yes Fails if the file cannot be determined to be
929928

930929
The file validation rules apply for both single and multiple file uploads.
931930

932-
.. note:: You can also use any native PHP functions that permit up
933-
to two parameters, where at least one is required (to pass
934-
the field data).
931+
.. note:: You can also use any native PHP functions that return boolean and
932+
permit at least one parameter, the field data to validate.
933+
The Validation library **never alters the data** to validate.

0 commit comments

Comments
 (0)