I'm creating my own validation and need to retrieve error messages from the localized file(resources/lang/en/validation.php and etc). The main task is to get array of error messages from the appropriate file. Usually, the validator does it and you don't need to worry about it. Does exist a way to get all these messages with no using validator?
You can access your translation files and their contents from anywhere with the global helper function trans
For example: your translations are in the file resources/lang/en/customvalidation.php
return [
'customerror' => 'my custom error message',
];
Then
trans('customvalidation.customerror')
will return "my custom error message" (depending on the current set language)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With