CodeIgniter Forums
Pre format rules ignored - CI4 Validation - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: Pre format rules ignored - CI4 Validation (/showthread.php?tid=77829)



Pre format rules ignored - CI4 Validation - SammieL - 10-23-2020

Hi Team,

If I apply any rule to CI4 Validation that returns string instead of boolean, that rule is skipped. No effect on data output / formatting.

Like this.

PHP Code:
$validation->setRules([
    'username' => 'trim|required',
    'password' => 'required|min_length[10]'
]); 

PHP Code:
$request->getPostGet('username'); // Username is not trimmed. 

This used to be working fine in CI3. How can I attain the same in CI4?


RE: Pre format rules ignored - CI4 Validation - InsiteFX - 10-23-2020

You need to run it through the validation.


RE: Pre format rules ignored - CI4 Validation - SammieL - 10-23-2020

(10-23-2020, 05:24 PM)InsiteFX Wrote: You need to run it through the validation.

I did create rules that has 'trim' rule,
Run the validation and I got true.
Input had spaces: '   sammiel    ';
I was hoping that after running the validation, I would get output without spaces. But the output had spaces as well - the reason why I posted my question in these forums.


RE: Pre format rules ignored - CI4 Validation - InsiteFX - 10-24-2020

Then you may have found a bug so report it on GitHub issues.


RE: Pre format rules ignored - CI4 Validation - mjamilasfihani - 10-24-2020

Why dont using alpha rule?


RE: Pre format rules ignored - CI4 Validation - paulbalandan - 10-24-2020

Can you show the whole code where you validate the username?