Pass Value to Replace a Custom Placeholder in a Laravel Validation Message
Leonel Elimpe
by Leonel Elimpe
~1 min read

Tags

  • Laravel
  • PHP

Say you have the following validation message in the custom array of your language file - resources/lang/xx/validation.php - (or another location depending on your use case).

<?php

return [
  
  // ...
  
  'custom' => [
      'email' => [
          'supported_email_provider' => ':provider not supported at this time.',
      ],
  ],
  
  // ...
];  

supported_email_provider is a custom validation rule here and :provider is a custom placeholder within the validation message.

Properly passing in a value for :provider has got me searching the web the last couple hours, fortunately, I found this Stack Overflow answer that provides a clean solution to this, check it out!

https://stackoverflow.com/a/50535139/6924437