Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: improve Note for in-Model Validation #8917

Merged
merged 2 commits into from
May 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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