Welcome Guest, Not a member yet? Register   Sign In
Pre format rules ignored - CI4 Validation
#1

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?
Reply
#2

You need to run it through the validation.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(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.
Reply
#4

Then you may have found a bug so report it on GitHub issues.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

Why dont using alpha rule?
Reply
#6

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




Theme © iAndrew 2016 - Forum software by © MyBB