Welcome Guest, Not a member yet? Register   Sign In
CI4 Validation how to set a different error message using 2 regex_match
#1

I have these rules


PHP Code:
'rules'  => 'required|min_length[8]|max_length[50]|regex_match[/\d/]|regex_match[/[^a-zA-Z\d]/]',
'errors' => [
             'required'    => 'Error for required',
             'min_length'  => 'Error for min_length',
             'max_length'  => 'Error for max_length',
             'regex_match' => 'Error for all 2 regex_match'
            ]; 


Is there a way to differentiate the text of the two regex_matches?
Reply
#2

Create a custom rule.
See https://codeigniter4.github.io/CodeIgnit...stom-rules
Reply
#3

(05-03-2022, 05:32 AM)kenjis Wrote: Create a custom rule.
See https://codeigniter4.github.io/CodeIgnit...stom-rules

Yes, I have already created some custom rules, I was just thinking it was the only solution, but I asked in case there was a native way
Reply
#4

It seems impossible.

It seems using a rule more than once is unexpected.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB