Skip to content

Commit 776b9cf

Browse files
committed
docs: update about Traditional Validation Rules
1 parent 530d5e1 commit 776b9cf

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

user_guide_src/source/libraries/validation.rst

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,29 @@ Traditional and Strict Rules
213213
============================
214214

215215
CodeIgniter 4 has two kinds of Validation rule classes.
216-
The traditional rule classes (**Traditional Rules**) have the namespace ``CodeIgniter\Validation``,
217-
and the new classes (**Strict Rules**) have ``CodeIgniter\Validation\StrictRules``, which provide strict validation.
216+
217+
The default rule classes (**Strict Rules**) have the namespace
218+
``CodeIgniter\Validation\StrictRules``, and they provide strict validation.
219+
220+
The traditional rule classes (**Traditional Rules**) have the namespace
221+
``CodeIgniter\Validation``. They are provided for backward compatibility only.
222+
They may not validate non-string values correctly and need not be used in new
223+
projects.
218224

219225
.. note:: Since v4.3.0, **Strict Rules** are used by default for better security.
220226

227+
Strict Rules
228+
------------
229+
230+
.. versionadded:: 4.2.0
231+
232+
The **Strict Rules** don't use implicit type conversion.
233+
221234
Traditional Rules
222235
-----------------
223236

224-
.. warning:: When validating data that contains non-string values, such as JSON data, it is recommended to use **Strict Rules**.
237+
.. warning:: When validating data that contains non-string values, such as JSON data,
238+
you should use **Strict Rules**.
225239

226240
The **Traditional Rules** implicitly assume that string values are validated,
227241
and the input value may be converted implicitly to a string value.
@@ -231,16 +245,13 @@ However, for example, if you use JSON input data, it may be a type of bool/null/
231245
When you validate the boolean ``true``, it is converted to string ``'1'`` with the Traditional rule classes.
232246
If you validate it with the ``integer`` rule, ``'1'`` passes the validation.
233247

234-
Strict Rules
235-
------------
236-
237-
.. versionadded:: 4.2.0
238-
239-
The **Strict Rules** don't use implicit type conversion.
240-
241248
Using Traditional Rules
242249
-----------------------
243250

251+
.. warning:: The **Traditional Rules** are provided for backward compatibility only.
252+
They may not validate non-string values correctly and need not be used in new
253+
projects.
254+
244255
If you want to use traditional rules, you need to change the rule classes in **app/Config/Validation.php**:
245256

246257
.. literalinclude:: validation/003.php

0 commit comments

Comments
 (0)