@@ -213,15 +213,29 @@ Traditional and Strict Rules
213
213
============================
214
214
215
215
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.
218
224
219
225
.. note :: Since v4.3.0, **Strict Rules** are used by default for better security.
220
226
227
+ Strict Rules
228
+ ------------
229
+
230
+ .. versionadded :: 4.2.0
231
+
232
+ The **Strict Rules ** don't use implicit type conversion.
233
+
221
234
Traditional Rules
222
235
-----------------
223
236
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 **.
225
239
226
240
The **Traditional Rules ** implicitly assume that string values are validated,
227
241
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/
231
245
When you validate the boolean ``true ``, it is converted to string ``'1' `` with the Traditional rule classes.
232
246
If you validate it with the ``integer `` rule, ``'1' `` passes the validation.
233
247
234
- Strict Rules
235
- ------------
236
-
237
- .. versionadded :: 4.2.0
238
-
239
- The **Strict Rules ** don't use implicit type conversion.
240
-
241
248
Using Traditional Rules
242
249
-----------------------
243
250
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
+
244
255
If you want to use traditional rules, you need to change the rule classes in **app/Config/Validation.php **:
245
256
246
257
.. literalinclude :: validation/003.php
0 commit comments