Skip to content

Commit ad0fb2c

Browse files
authored
Merge pull request #8331 from kenjis/docs-update-valiation-sample
docs: use validateData() instead of validate() in Validation
2 parents f81dd1a + 50f7633 commit ad0fb2c

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

user_guide_src/source/libraries/validation.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,13 @@ To try your form, visit your site using a URL similar to this one::
147147
example.com/index.php/form/
148148

149149
If you submit the form you should simply see the form reload. That's
150-
because you haven't set up any validation rules in ``$this->validate()`` yet.
150+
because you haven't set up any validation rules in :ref:`controller-validatedata` yet.
151151

152-
The ``validate()`` method is a method in the Controller. It uses
153-
the **Validation class** inside. See :ref:`controllers-validating-data`.
152+
The ``validateData()`` method is a method in the Controller. It uses
153+
the **Validation class** inside. See :ref:`controller-validatedata`.
154154

155-
.. note:: Since you haven't told the ``validate()`` method to validate anything
156-
yet, it **returns false** (boolean false) **by default**. The ``validate()``
155+
.. note:: Since you haven't told the ``validateData()`` method to validate anything
156+
yet, it **returns false** (boolean false) **by default**. The ``validateData()``
157157
method only returns true if it has successfully applied your rules without
158158
any of them failing.
159159

@@ -189,7 +189,7 @@ It loads the form helper used by your view files.
189189

190190
The controller has one method: ``index()``. This method returns
191191
the **signup** view to show the form when a non-POST request comes. Otherwise, it
192-
uses the Controller-provided ``validate()`` method. It also runs the validation routine.
192+
uses the Controller-provided :ref:`controller-validatedata` method. It also runs the validation routine.
193193
Based on whether the validation was successful it either presents the
194194
form or the success page.
195195

user_guide_src/source/libraries/validation/001.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ public function index()
1212
return view('signup');
1313
}
1414

15-
$rules = [];
15+
$rules = [
16+
// @TODO
17+
];
1618

17-
if (! $this->validate($rules)) {
19+
$data = $this->request->getPost(array_keys($rules));
20+
21+
if (! $this->validateData($data, $rules)) {
1822
return view('signup');
1923
}
2024

0 commit comments

Comments
 (0)