CodeIgniter Forums
Form Validation Config File - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19)
+--- Thread: Form Validation Config File (/showthread.php?tid=76179)



Form Validation Config File - hafijul233 - 04-19-2020

Hello, I am new on this forum
I have problem with creating a form_validation.php file for entire application validation
I want custom error message for regex_match but. I got Default Error Validation Message

PHP Code:
//form validation regular expression
defined('NAME_EXP') OR define('NAME_EXP''[a-zA-Z .\-]+$');

'applicant' => [
    'field' => 'full_name',
    'label' => 'Applicant Name',
    'rules' => 'trim|required|max_length[255]|min_length[3]|regex_match[/' NAME_EXP '/]',
    'errors' => [
        'regex_match[/' NAME_EXP '/]' => "The %s field may only contain Alphabetic characters, Fullstops(.), Hyphens(-) and spaces( )."
    ]




RE: Form Validation Config File - jreklund - 04-19-2020

Hi, you should do it like this:

PHP Code:
'errors' => [
        
'regex_match' => ...
    ] 



RE: Form Validation Config File - hafijul233 - 04-19-2020

thank you. it works fine