@@ -168,7 +168,7 @@ public function run(?array $data = null, ?string $group = null, ?string $dbGroup
168
168
if (strpos ($ field , '* ' ) !== false ) {
169
169
// Process multiple fields
170
170
foreach ($ values as $ dotField => $ value ) {
171
- $ this ->processRules ($ dotField , $ setup ['label ' ] ?? $ field , $ value , $ rules , $ data );
171
+ $ this ->processRules ($ dotField , $ setup ['label ' ] ?? $ field , $ value , $ rules , $ data, $ field );
172
172
}
173
173
} else {
174
174
// Process single field
@@ -201,10 +201,17 @@ public function check($value, string $rule, array $errors = []): bool
201
201
*
202
202
* @param array|string $value
203
203
* @param array|null $rules
204
- * @param array $data
204
+ * @param array $data The array of data to validate, with `DBGroup`.
205
+ * @param string|null $originalField The original asterisk field name like "foo.*.bar".
205
206
*/
206
- protected function processRules (string $ field , ?string $ label , $ value , $ rules = null , ?array $ data = null ): bool
207
- {
207
+ protected function processRules (
208
+ string $ field ,
209
+ ?string $ label ,
210
+ $ value ,
211
+ $ rules = null ,
212
+ ?array $ data = null ,
213
+ ?string $ originalField = null
214
+ ): bool {
208
215
if ($ data === null ) {
209
216
throw new InvalidArgumentException ('You must supply the parameter: data. ' );
210
217
}
@@ -333,7 +340,8 @@ protected function processRules(string $field, ?string $label, $value, $rules =
333
340
$ field ,
334
341
$ label ,
335
342
$ param ,
336
- (string ) $ value
343
+ (string ) $ value ,
344
+ $ originalField
337
345
);
338
346
339
347
return false ;
@@ -706,13 +714,21 @@ public function setError(string $field, string $error): ValidationInterface
706
714
*
707
715
* @param string|null $value The value that caused the validation to fail.
708
716
*/
709
- protected function getErrorMessage (string $ rule , string $ field , ?string $ label = null , ?string $ param = null , ?string $ value = null ): string
710
- {
717
+ protected function getErrorMessage (
718
+ string $ rule ,
719
+ string $ field ,
720
+ ?string $ label = null ,
721
+ ?string $ param = null ,
722
+ ?string $ value = null ,
723
+ ?string $ originalField = null
724
+ ): string {
711
725
$ param ??= '' ;
712
726
713
727
// Check if custom message has been defined by user
714
728
if (isset ($ this ->customErrors [$ field ][$ rule ])) {
715
729
$ message = lang ($ this ->customErrors [$ field ][$ rule ]);
730
+ } elseif (null !== $ originalField && isset ($ this ->customErrors [$ originalField ][$ rule ])) {
731
+ $ message = lang ($ this ->customErrors [$ originalField ][$ rule ]);
716
732
} else {
717
733
// Try to grab a localized version of the message...
718
734
// lang() will return the rule name back if not found,
0 commit comments