Skip to content

Commit

Permalink
Merge pull request #8917 from kenjis/docs-model-validation-note
Browse files Browse the repository at this point in the history
docs: improve Note for in-Model Validation
  • Loading branch information
kenjis authored May 30, 2024
2 parents 117dc1d + e19fc09 commit cc33865
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions user_guide_src/source/models/model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ CodeIgniter does provide a model class that has a few nice features, including:

- automatic database connection
- basic CRUD methods
- in-model validation
- :ref:`in-model validation <in-model-validation>`
- :ref:`automatic pagination <paginating-with-models>`
- and more

Expand Down Expand Up @@ -659,9 +659,14 @@ prior to saving to the database with the ``insert()``, ``update()``, or ``save()
.. important:: When you update data, by default, the validation in the model class only
validates provided fields. This is to avoid validation errors when updating only some fields.

But this means ``required*`` rules do not work as expected when updating.
If you want to check required fields, you can change the behavior by configuration.
See :ref:`clean-validation-rules` for details.
However, this means that not all validation rules you set will be checked
during updates. Thus, incomplete data may pass the validation.

For example, ``required*`` rules or ``is_unique`` rule that require the
values of other fields may not work as expected.

To avoid such glitches, this behavior can be changed by configuration. See
:ref:`clean-validation-rules` for details.

Setting Validation Rules
------------------------
Expand Down

0 comments on commit cc33865

Please sign in to comment.