In Laravel 9 you can use the :position placeholder in validation messages if you're working with arrays.
This will output: "Please provide an amount for price #2"
1class CreateProductRequest extends FormRequest 2{ 3 public function rules(): array 4 { 5 return [ 6 'title' => ['required', 'string']; 7 'description' => ['nullable', 'sometimes', 'string'], 8 'prices' => ['required', 'array'], 9 'prices.*.amount' => ['required', 'numeric'],10 'prices.*.expired_at' => ['required', 'date'],11 ];12 }13 14 public function messages(): array15 {16 'prices.*.amount.required' => 'Please provide an amount for price #:position'17 }18}
Tip given by @mmartin_joo