CodeIgniter Forums
validation in the file model - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: validation in the file model (/showthread.php?tid=88817)



validation in the file model - Vitor Hugo Furtado - 11-14-2023

I need to validate files using codeigniter 4 and when placing validation rules, I also need to allow empty, but when using the "permit empty" rule it ignores all other rules.
'course' => 'permit_empty|max_size[course,2000]|ext_in[pdf,tar,zip]'


RE: validation in the file model - kenjis - 11-14-2023

See the note at the end.
https://codeigniter4.github.io/userguide/libraries/validation.html#rules-for-file-uploads


RE: validation in the file model - Vitor Hugo Furtado - 11-16-2023

Ok, I saw this note, but is there no other way?


RE: validation in the file model - kenjis - 11-16-2023

In conclusion, only Rules for File Uploads should be used for uploaded files. Otherwise, you will not get the expected results.

If the existing rules do not work for you, create a custom rule.

Quote:uploaded
...
If you want the file upload to be optional
(not required), do not define this rule.
https://codeigniter4.github.io/userguide/libraries/validation.html#rules-for-file-uploads