mercredi 14 octobre 2015

Custom Validation Replacers in Laravel 5.1

I am trying to create a custom validation replacer in my Laravel 5.1 application.

I currently have

Validator::replacer('year', 'App\CustomValidators@replaceYear');

in my AppServiceProvider file with the corresponding living in my custom class. However when I include :year in a validation message, it is not replaced. what am I missing?

Here's my replacer function.

public function replaceYear($message, $attribute, $rule, $parameters)
{
    return str_replace([':year'], $parameters, $message);
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire