![]() |
Validation Rules: Valid email, but allow null? - 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: Validation Rules: Valid email, but allow null? (/showthread.php?tid=92932) |
Validation Rules: Valid email, but allow null? - sevmusic - 05-19-2025 In my app I have 2 email address fields. The first field is required because it's the main account. The second field is optional. Here are my rules currently. PHP Code: public $profile = [ But when I leave the login_email_2 field blank it complains that it's not a valid email. How can I ignore the valid email rule if the field is blank? I think I solved my own problem with permit_empty Is there a listing of all the codeigniter validation rules? I didn't see them singled out in the docs. RE: Validation Rules: Valid email, but allow null? - grimpirate - 05-19-2025 Rules for General Use. RE: Validation Rules: Valid email, but allow null? - InsiteFX - 05-19-2025 You can not have an email that is empty using that rule, you could check it an see if it has a value in your code then set it to permit_empty and remove the valid_email one check it in your code. RE: Validation Rules: Valid email, but allow null? - sevmusic - 05-22-2025 (05-19-2025, 09:28 PM)grimpirate Wrote: Rules for General Use.Thank you! |