add validation message with replacer
This commit is contained in:
parent
a80a93c94c
commit
a8a3774305
|
|
@ -3,16 +3,25 @@
|
|||
namespace LaravelProfane;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Lang;
|
||||
|
||||
class ProfaneServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function register()
|
||||
{
|
||||
# code...
|
||||
$this->loadTranslationsFrom(__DIR__.'/lang', 'laravel-profane');
|
||||
|
||||
$this->publishes([
|
||||
__DIR__.'/lang' => resource_path('lang/vendor/laravel-profane'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function boot()
|
||||
{
|
||||
Validator::extend('profane', 'LaravelProfane\ProfaneValidator@validate');
|
||||
|
||||
Validator::replacer('profane', function($message, $attribute, $rule, $parameters) {
|
||||
return str_replace(':attribute', $attribute, $message);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'profane' => 'The :attribute contains vulgar content'
|
||||
];
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'profane' => 'El :attribute contiene palabras vulgares.'
|
||||
];
|
||||
Loading…
Reference in New Issue