Could we help you? Please click the banners. We are young and desperately need the money
Laravel allows you to define custom error messages for validation rules using key-value pairs where the key is the rule name and the value the custom message.
<?php
[
'required' => 'foo is required.',
'string' => 'foo must be a stirng.',
]
?>
While the names for built-in rules are obvious, it may not be as obvious for custom rules. The official Laravel documentation doesn't mention this anywhere, but you're supposed to use class strings.
<?php
[
MyCustomRule::class => 'foo needs to abide my custom rule.',
]
?>
However, for anonymous custom rules (that use functions), there unfortunately doesn't seem to be an elegant way to define custom messages.