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?

3
  • In previous Laravel versions you could do this with a replacer, eg stackoverflow.com/questions/30025252/…, stackoverflow.com/questions/30025252/…, but the relevant info seems to have disappeared from the docs for 8.x. Commented Apr 28, 2021 at 7:20
  • I don't know why they removed it from document, but it still work in laravel 9.x, both extend() and replacer() method. Commented Nov 17, 2022 at 2:47
  • In L9, I found that we could do that by changing in FormRequest object. Commented Nov 17, 2022 at 5:20

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.