-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Labels
bugVerified issues on the current code behavior or pull requests that will fix themVerified issues on the current code behavior or pull requests that will fix them
Description
CodeIgniter4 Version
dev
What happened?
If you specify a custom error message for a field with an asterisk, the default error text will be used.
This is due to the fact that a field without an asterisk is passed to generate an error (it contains the full path of the key)
Steps to Reproduce
$data = [
'user' => [
['name' => null],
['name' => null],
]
];
$validator = Services::validation();
$validator->setRules(['user.*.name' => 'required'], ['user.*.name' => ['required' => 'Required']]);
$validator->run($data);
dd($validator->getErrors());
// array (2) [
// 'user.0.name' => 'The user.*.name field is required.'
// 'user.1.name' => 'The user.*.name field is required.'
// ]
Expected Output
array (2) [
'user.0.name' => 'Required'
'user.1.name' => 'Required'
]
Metadata
Metadata
Assignees
Labels
bugVerified issues on the current code behavior or pull requests that will fix themVerified issues on the current code behavior or pull requests that will fix them