2

I wonder if there is anyway to format the numeric value of Laravel validation messages. For example, the validation rule 'min':

'min' => [
    'numeric' => 'The :attribute must be at least :min.',
    'file' => 'The :attribute must be at least :min kilobytes.',
    'string' => 'The :attribute must be at least :min characters.',
    'array' => 'The :attribute must have at least :min items.',
],

My value of ':min' is 50000. I want to display it with thousand separator 50,000. Is there any ideas?

Tommy Hoang
  • 157
  • 8
  • In previous Laravel versions you could do this with a `replacer`, eg https://stackoverflow.com/questions/30025252/laravel-extended-validation-custom-message, https://stackoverflow.com/questions/30025252/laravel-extended-validation-custom-message, but the relevant info seems to have disappeared from the docs for 8.x. – Don't Panic Apr 28 '21 at 07:20
  • I don't know why they removed it from document, but it still work in laravel 9.x, both extend() and replacer() method. – le hien Nov 17 '22 at 02:47
  • In L9, I found that we could do that by changing in FormRequest object. – Tommy Hoang Nov 17 '22 at 05:20

0 Answers0