Skip to content

Commit 1abc4b5

Browse files
authored
Merge pull request #5480 from kenjis/fix-docs-validation.rst
docs: improve validation.rst
2 parents ee48a4c + d2f12fb commit 1abc4b5

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

user_guide_src/source/libraries/validation.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -527,10 +527,12 @@ or the value that was validated you can add the ``{field}``, ``{param}`` and ``{
527527

528528
'min_length' => 'Supplied value ({value}) for {field} must have at least {param} characters.'
529529

530-
On a field with the human name Username and a rule of min_length[6] with a value of “Pizza”, an error would display: “Supplied value (Pizza) for Username must have
530+
On a field with the human name Username and a rule of ``min_length[6]`` with a value of “Pizza”, an error would display: “Supplied value (Pizza) for Username must have
531531
at least 6 characters.”
532532

533-
.. note:: If you pass the last parameter the labeled style error messages will be ignored.
533+
.. warning:: If you get the error messages with ``getErrors()`` or ``getError()``, the messages are not HTML escaped. If you use user input data like ``({value})`` to make the error message, it might contain HTML tags. If you don't escape the messages before displying them, XSS attacks are possible.
534+
535+
.. note:: When using label-style error messages, if you pass the second parameter to ``setRules()``, it will be overwritten with the value of the first parameter.
534536

535537
Translation Of Messages And Validation Labels
536538
=============================================
@@ -592,7 +594,7 @@ You can check to see if an error exists with the ``hasError()`` method. The only
592594
}
593595

594596
Customizing Error Display
595-
************************************************
597+
*************************
596598

597599
When you call ``$validation->listErrors()`` or ``$validation->showError()``, it loads a view file in the background
598600
that determines how the errors are displayed. By default, they display with a class of ``errors`` on the wrapping div.
@@ -643,11 +645,11 @@ short alias they can be referenced by. If we were to add our example file from a
643645
Specifying the Template
644646
=======================
645647

646-
You can specify the template to use by passing it's alias as the first parameter in ``listErrors``::
648+
You can specify the template to use by passing it's alias as the first parameter in ``listErrors()``::
647649

648650
<?= $validation->listErrors('my_list') ?>
649651

650-
When showing field-specific errors, you can pass the alias as the second parameter to the ``showError`` method,
652+
When showing field-specific errors, you can pass the alias as the second parameter to the ``showError()`` method,
651653
right after the name of the field the error should belong to::
652654

653655
<?= $validation->showError('username', 'my_single') ?>

0 commit comments

Comments
 (0)