Welcome Guest, Not a member yet? Register   Sign In
Encryption and validation
#1

(This post was last modified: 03-13-2022, 07:58 AM by sprhld.)

Hello!

My new learning is encryption. But I got some curios results regarding validate data before store:

This is my validation rule for a specific field:

PHP Code:
'number'  => 'required|decimal|trim'

And this is the code how I decode it. I use a own helper decode() to do so, because this helper I can use everywhere and I don't have to load it on serveral points in my app. Data is from a from.

PHP Code:
    public function add ($data)
    {
        $inserts = [
            'number' => encode($data['qm']),
        ];

        return $this->builder()->insert($inserts);
    

If I send "AAA" to the form, it will decoded stored. But this is wrong. First, AAA is not a number. But this is not checked. So It should the decoded string validated, but this isn't to. In an other case/model, I use an entity where I encode and decode, but with the same result, that the validation from the model is not used.

How to combine encryption and validation? So I want to validate and then decode and store the data.
Reply
#2

Hello. are you following this:

https://www.codeigniter.com/userguide3/l...encryption
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
Reply




Theme © iAndrew 2016 - Forum software by © MyBB