Validation Bug?? |
Hi
There seems to be a problem with form validation (Ci4). IS THIS A BUG ???? I have writtem my validation rules to config/validation.php as per the documentation. The problem is two-fold. 1) Assuming the "Rules for File Upload" interrogate the file header the following do not seem to work at all ( max_size, mime_in, ext_in), and, 2) the configured error message configured for the rule is not return when the validation fails. Please see the following: Script PHP Code: $file = $this->request->getFile('image'); //file upload.jpg mime = image/jpg, size = 35475 extension = jpg Validation PHP Code: public $image_upload = [ The above returns {"file":"file does not have a valid mime type.","id":"The id field is required"} 1) There should NOT be errors 2) If there is errors the above should return {"file":"Invalid Image File. Only jpg, jpeg, gif or png allowed","id":"User Not Defined."} Now if I run the following validation (to ensure the validator is configured properly).. PHP Code: $validation_array=array('file'=>$file, 'id'=>'7'); The above returns {"file":"file does not have a valid mime type."} If there is errors the above should return {"file":"Invalid Image File. Only jpg, jpeg, gif or png allowed",} IS THIS A BUG ?????? Many thanks (in advance).
Change this:
Code: public $image_upload = [ to PHP Code: public $image_upload = [ Validation checks against the names in your form input (post/get values) not your variables after it has been submitted. So if your form file input is named "image" which it looks like it is then you have to use "image" in your validation. |
Welcome Guest, Not a member yet? Register Sign In |