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"
class CreateProductRequest extends FormRequest{ public function rules(): array { return [ 'title' => ['required', 'string']; 'description' => ['nullable', 'sometimes', 'string'], 'prices' => ['required', 'array'], 'prices.*.amount' => ['required', 'numeric'], 'prices.*.expired_at' => ['required', 'date'], ]; } public function messages(): array { 'prices.*.amount.required' => 'Please provide an amount for price #:position' }}
Tip given by @mmartin_joo