diff --git a/user_guide_src/source/libraries/validation.rst b/user_guide_src/source/libraries/validation.rst index d8df45d1c95c..1779877c50b1 100644 --- a/user_guide_src/source/libraries/validation.rst +++ b/user_guide_src/source/libraries/validation.rst @@ -33,8 +33,7 @@ On the receiving end, the script must: be someone else's existing username, or perhaps even a reserved word. Etc. #. Sanitize the data for security. -#. Pre-format the data if needed (Does the data need to be trimmed? HTML - encoded? Etc.) +#. Pre-format the data if needed. #. Prep the data for insertion in the database. Although there is nothing terribly complex about the above process, it @@ -233,7 +232,7 @@ that should be applied:: $validation->setRule('username', 'Username', 'required'); The **field name** must match the key of any data array that is sent in. If -the data is taken directly from $_POST, then it must be an exact match for +the data is taken directly from ``$_POST``, then it must be an exact match for the form input name. setRules() @@ -440,7 +439,7 @@ Validation Placeholders The Validation class provides a simple method to replace parts of your rules based on data that's being passed into it. This sounds fairly obscure but can be especially handy with the ``is_unique`` validation rule. Placeholders are simply -the name of the field (or array key) that was passed in as $data surrounded by curly brackets. It will be +the name of the field (or array key) that was passed in as ``$data`` surrounded by curly brackets. It will be replaced by the **value** of the matched incoming field. An example should clarify this:: $validation->setRules([ @@ -687,7 +686,7 @@ a boolean true or false value signifying true if it passed the test or false if } By default, the system will look within ``CodeIgniter\Language\en\Validation.php`` for the language strings used -within errors. In custom rules, you may provide error messages by accepting a $error variable by reference in the +within errors. In custom rules, you may provide error messages by accepting a ``$error`` variable by reference in the second parameter:: public function even(string $str, string &$error = null): bool @@ -711,7 +710,7 @@ Allowing Parameters =================== If your method needs to work with parameters, the function will need a minimum of three parameters: the string to validate, -the parameter string, and an array with all of the data that was submitted the form. The $data array is especially handy +the parameter string, and an array with all of the data that was submitted the form. The ``$data`` array is especially handy for rules like ``require_with`` that needs to check the value of another submitted field to base its result on:: 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 The file validation rules apply for both single and multiple file uploads. -.. note:: You can also use any native PHP functions that permit up - to two parameters, where at least one is required (to pass - the field data). +.. note:: You can also use any native PHP functions that return boolean and + permit at least one parameter, the field data to validate. + The Validation library **never alters the data** to validate.