-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Add note that only file rules can be used to validate files #7969
Add note that only file rules can be used to validate files #7969
Conversation
Therefore, adding any general rules, like ``permit_empy``, to file validation rules array or string will prevend all rules for the | ||
from file from being processed during validation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get well "prevend all rules for the from file from being processed during validation."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this?
Therefore, adding any general rules, like ``permit_empy``, to file validation rules array or string will prevend all rules for the | |
from file from being processed during validation. | |
Therefore, if you add any general rules, like ``permit_empy`` to file validation rules array or string, | |
the file validation will not work correctly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, if you set rules 'permit_empty|max_size[profile_img,1024]|mime_in[profile_img,image/jpeg]', you can uplood 3mb pdf's, and validation will pass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, but I cannot believe I messed up my English that much... sorry.
Should be:
general rules, like
permit_empy
, to file validation rules array or string will prevent all rules for the file form field from being processed during validation (thus validating even invalid files).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
permit_empty
(or other general rules) checks $_POST
array, and the field for the file upload does not exist, so the validation passes.
However, most rules do not permit empty, and $_POST
has no field for it, so if set, the validation will fail.
I don't know how to explain it briefly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, it's complicated. I was also thinking about filing a bug report (it is not good that adding a stray rule disables the other rules), but now I suspect that it is more of a limitation of validation than a bug...
Therefore, adding any general rules, like ``permit_empy``, to file validation rules array or string will prevend all rules for the | ||
from file from being processed during validation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this?
Therefore, adding any general rules, like ``permit_empy``, to file validation rules array or string will prevend all rules for the | |
from file from being processed during validation. | |
Rules for General Use like ``permit_empty`` do not check the uploaded file (in the ``$_FILES`` superglobal), | |
therefore, adding these rules to file validation rules array or string will not yield the expected results. |
@@ -992,3 +995,7 @@ is_image Yes Fails if the file cannot be determined to be | |||
======================= ========== ============================================= =================================================== | |||
|
|||
The file validation rules apply for both single and multiple file uploads. | |||
|
|||
.. note:: Only rules specifically created for file validation (like the ones listed in the table above) can be used to validate files. | |||
Therefore, adding any general rules, like ``permit_empy``, to file validation rules array or string will prevend all rules for the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A rule typo:
Therefore, adding any general rules, like ``permit_empy``, to file validation rules array or string will prevend all rules for the | |
Therefore, adding any general rules, like ``permit_empty``, to file validation rules array or string will prevend all rules for the |
https://github.com/codeigniter4/CodeIgniter4/actions/runs/6407584328/job/17394669739?pr=7969 |
Yep, see that now, will fix later today. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Also add explanation regarding rule
uploaded
, that it makes the file upload required.