@@ -201,10 +201,17 @@ Config for Validation
201
201
Traditional and Strict Rules
202
202
============================
203
203
204
- CI4 has two kinds of Validation rule classes.
205
- The default rule classes (**Traditional Rules **) have the namespace ``CodeIgniter\Validation ``,
204
+ CodeIgniter 4 has two kinds of Validation rule classes.
205
+ The traditional rule classes (**Traditional Rules **) have the namespace ``CodeIgniter\Validation ``,
206
206
and the new classes (**Strict Rules **) have ``CodeIgniter\Validation\StrictRules ``, which provide strict validation.
207
207
208
+ .. note :: Since v4.3.0, **Strict Rules** are used by default for better security.
209
+
210
+ Traditional Rules
211
+ -----------------
212
+
213
+ .. warning :: When validating data that contains non-string values, such as JSON data, it is recommended to use **Strict Rules**.
214
+
208
215
The **Traditional Rules ** implicitly assume that string values are validated,
209
216
and the input value may be converted implicitly to a string value.
210
217
It works for most basic cases like validating POST data.
@@ -213,14 +220,17 @@ However, for example, if you use JSON input data, it may be a type of bool/null/
213
220
When you validate the boolean ``true ``, it is converted to string ``'1' `` with the Traditional rule classes.
214
221
If you validate it with the ``integer `` rule, ``'1' `` passes the validation.
215
222
216
- The **Strict Rules ** don't use implicit type conversion.
223
+ Strict Rules
224
+ ------------
217
225
218
- .. warning :: When validating data that contains non-string values, such as JSON data, it is recommended to use **Strict Rules**.
226
+ .. versionadded :: 4.2.0
227
+
228
+ The **Strict Rules ** don't use implicit type conversion.
219
229
220
- Using Strict Rules
221
- ------------------
230
+ Using Traditional Rules
231
+ -----------------------
222
232
223
- If you want to use these rules, you need to change the rule classes in **app/Config/Validation.php **:
233
+ If you want to use traditional rules, you need to change the rule classes in **app/Config/Validation.php **:
224
234
225
235
.. literalinclude :: validation/003.php
226
236
0 commit comments