![]() |
How rules works? - 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: How rules works? (/showthread.php?tid=88340) |
How rules works? - motoroller - 08-25-2023 please explain how its works if_exist? What difference permit_empty? RE: How rules works? - sammyskills - 08-25-2023 From the docs, Quote:if_exists: If this rule is present, validation will check the field only when the field key exists in the data to validate. More explanation: Validation will only check the field when the field key is present in the request data to validate. For example, you set the rule on a field like so: PHP Code: $rule = ['username' => "if_exists|numeric"]; Quote:permit_empty: Allows the field to receive an empty array, empty string, null or false. More explanation: Validation will allow a field to accept an empty value, irrespective of the associated rules. For example, you set the rule on a field like so: PHP Code: $rule = ['username' => "permit_empty|numeric"]; |