Hi Laravel-ers,
I am doing FormRequest validation. I am using the array rule (https://laravel.com/docs/10.x/validation#rule-array) to ensure that only specified keys are allowed in the validated array. For example:
$rules = [
'example' => ['array:something,another'],
];
However, if this rule encounters an array key that isn't in that whitelist the error message I get isn't very descriptive:
The :attribute field must be an array. (https://github.com/laravel/framework/blob/10.x/src/Illuminate/Translation/lang/en/validation.php#L24)
This message doesn't reference the incorrect array key at all, making it hard for the end user to work out what they did wrong.
Can I improve this error message such that it highlights the fact that an incorrect key has been passed?
I would have thought that this has been asked before but my Google-fu clearly isn't strong today!
Thanks for your help,
Ari