I don't think that my validator extentions are working, but I can't fathom why.
Service Provider.
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Validator::extend('fail', function ($attribute, $value, $parameters, $validator) {
return false;
});
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
}
}
I know the Service Provider's boot is firing because if I dd();
inside the boot method I get output. If I add a dd();
to the extend closure function, I do not get any output.
Request
class SaveOrder extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$rules = [
'customer_id' => 'in:' . Customer::getImplodedCurrentTeamKeys(),
'pin' => 'fail'
];
return $rules;
}
}
I know the request is validating correctly because if I change the rule to 'pin' => 'required'
and don't give in put I get a fail.
Why is my custom validation rule not working?
via Samuel Hawksby-Robinson