2017-12-18 11 views

答えて

4

あなたはこのようにカスタムのリクエストクラスでgetValidatorInstance()メソッドをオーバーライドすることができます。

protected function getValidatorInstance() 
{ 
    $validator = parent::getValidatorInstance(); 

    // here you can apply hook (example hook taken from documentation): 

    $validator->after(function ($validator) { 
     if ($this->somethingElseIsInvalid()) { 
      $validator->errors()->add('field', 'Something is wrong with this field!'); 
     } 
    }); 

    return $validator; 
} 
関連する問題