@@ -243,13 +243,13 @@ $validationRules
243
243
244
244
Contains either an array of validation rules as described in :ref: `validation-array `
245
245
or a string containing the name of a validation group, as described in the same section.
246
- Described in more detail below .
246
+ See also :ref: ` model-setting-validation-rules ` .
247
247
248
248
$validationMessages
249
249
^^^^^^^^^^^^^^^^^^^
250
250
251
251
Contains an array of custom error messages that should be used during validation, as
252
- described in :ref: `validation-custom-errors `. Described in more detail below .
252
+ described in :ref: `validation-custom-errors `. See also :ref: ` model-setting-validation-rules ` .
253
253
254
254
$skipValidation
255
255
^^^^^^^^^^^^^^^
@@ -649,11 +649,14 @@ Cleans out the database table by permanently removing all rows that have 'delete
649
649
In-Model Validation
650
650
===================
651
651
652
+ .. warning :: In-Model validation is performed just before data is stored in the
653
+ database. Prior to that point, the data has not yet been validated. Processing
654
+ user-input data prior to validation may introduce vulnerabilities.
655
+
652
656
Validating Data
653
657
---------------
654
658
655
- For many people, validating data in the model is the preferred way to ensure the data is kept to a single
656
- standard, without duplicating code. The Model class provides a way to automatically have all data validated
659
+ The Model class provides a way to automatically have all data validated
657
660
prior to saving to the database with the ``insert() ``, ``update() ``, or ``save() `` methods.
658
661
659
662
.. important :: When you update data, by default, the validation in the model class only
@@ -668,16 +671,24 @@ prior to saving to the database with the ``insert()``, ``update()``, or ``save()
668
671
To avoid such glitches, this behavior can be changed by configuration. See
669
672
:ref: `clean-validation-rules ` for details.
670
673
674
+ .. _model-setting-validation-rules :
675
+
671
676
Setting Validation Rules
672
677
------------------------
673
678
674
- The first step is to fill out the `$validationRules `_ class property with the fields and rules that should
675
- be applied. If you have custom error message that you want to use, place them in the `$validationMessages `_ array:
679
+ The first step is to fill out the `$validationRules `_ class property with the
680
+ fields and rules that should be applied.
681
+
682
+ .. note :: You can see the list of built-in Validation rules in :ref:`validation-available-rules`.
683
+
684
+ If you have custom error message that you want to use, place them in the `$validationMessages `_ array:
676
685
677
686
.. literalinclude :: model/027.php
678
687
679
- If you'd rather organize your rules and error messages within the Validation configuration file, you can do that
680
- and simply set `$validationRules `_ to the name of the validation rule group you created:
688
+ If you'd rather organize your rules and error messages within the
689
+ :ref: `Validation Config File <saving-validation-rules-to-config-file >`, you can
690
+ do that and simply set `$validationRules `_ to the name of the validation rule
691
+ group you created:
681
692
682
693
.. literalinclude :: model/034.php
683
694
0 commit comments