PHP Version
7.4
CodeIgniter4 Version
4.2.1
CodeIgniter4 Installation Method
Composer (using codeigniter4/appstarter)
Which operating systems have you tested for this bug?
Linux
Which server did you use?
fpm-fcgi
Database
No response
What happened?
Using the Built-in Validation class,
custom validation error message previously set is cleared when setting another rule.
Steps to Reproduce
$va = \Config\Services::validation();
$va->setRule("field1", "Field 1", ["required"], ["required" => "You must input field 1"] );
$va->setRule("field2", "Field 2", ["required"], ["required" => "You must input field 2"] );
$va->run([]);
$errors = $va->getErrors();
echo $errors["field1"] . "/" . $errors["field2"];
Expected Output
You must input field 1/You must input field 2
but
The field1 is required. / You must input field 2
Anything else?
It seems that the setRule() method calls getRules() internally to get rules already set, but it does not supply customErrors.
PHP Version
7.4
CodeIgniter4 Version
4.2.1
CodeIgniter4 Installation Method
Composer (using
codeigniter4/appstarter)Which operating systems have you tested for this bug?
Linux
Which server did you use?
fpm-fcgi
Database
No response
What happened?
Using the Built-in Validation class,
custom validation error message previously set is cleared when setting another rule.
Steps to Reproduce
Expected Output
but
Anything else?
It seems that the
setRule()method callsgetRules()internally to get rules already set, but it does not supplycustomErrors.