I am creating a rule for my validation on my laravel app.
i wrote my rules below
public function rules()
{
return [
'title' => 'required|string',
'taxonomies' => 'required|array',
'taxonomies.*.id' => 'required|string|exists:taxonomies,id',
'taxonomies.*.values' => 'required|array|min:2',
'taxonomies.*.values.*' => 'required',
'currency' => 'required|string',
'client_budget' => 'required|numeric',
];
}
in 'taxonomies.*.values.*' i will be expecting an array which every key on array['values'] should not be empty
eg.
this is what i expect
[
'taxonomies' => [
'0' => [
'id' => 7,
'values' => [
'key1' => 'own value',
'key2' => 'own value',
'key3' => 'own value'
],
],
'1' => [
'id' => 12,
'values' => [
'key1' => 'own value',
'key2' => 'own value',
'key3' => 'own value'
],
]
]
];
so if by any change a key is missing it should show an error this is working fine but When showing error message for 'taxonomies..values.', is display as
"The taxonomies.0.values.key1 field is required."
i want it to show something link this
The key1 value is required at array 0
How will i achieve this?
taxonomiesand write a custom message for each required message. you can create a generic function to make the error message.