![]() |
Validate Entities in Model - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Validate Entities in Model (/showthread.php?tid=77283) |
Validate Entities in Model - arnisraido - 08-11-2020 I am trying to validate Entity by calling Model->validate( Entities\Promocodes $promo ). But It looks like `Model->validate( Array $promo )` is the only option for this? I have an Entitiy class: PHP Code: namespace App\Entities; And I have a model with validation rules. Which works great, if I pass an Array to it. But it will always return true, if I pass Entities class Object. Model with validation rules: PHP Code: namespace App\Models; This will return false, as expected: PHP Code: model('PromocodesModel')->validate(['code'=> 'a']); // min length must be 3! The problem PHP Code: // Validating Entities object Will ALWAYS return TRUE! I understand, that passing Entities Object to Model may not be possible by design. But this is confusing in that case, because it should not return True anyway! I have workaround by always using Array for data fill, validate, but I would like to know, if there is sych Entities validation available, or this should be posted as feature request? |