mardi 2 juin 2020

Laravel validation messages array indices starting from 0

If in a form request I have rules

[
    'items' => ['required', 'array'],
    'items.*' => ['required', 'numeric'],
]

Then error message returns like this:

"items.0" => array:1 [
  0 => "The selected items.0 is invalid."
]

Is there any way to have the message look like "The selected items #1 is invalid" or something similar, that is actually human readable?

Please note, I need this for the whole system globally, there's already >500 form request classes, although not that many are using array validation, so changing extended class or adding a trait wouldn't be too horrible



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire