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.