jeudi 22 septembre 2016

attaching an error to validator in laravel 5

I'm using Validator Facade , here's the code

  $req = Request::all();
  $rules = ['name'=>'required|min:3|max:20'];
  $validator = Validator::make($req, $rules);

  if(/*another problem*/){
      // ??
  }      

  if ($validator->fails()) {
      return redirect()->back()->withErrors($validator)->withInput();
  }

I want to keep the errors that the laravel's Validator make's It self and attach some other's to It
so for example If there was nothing wrong with the name input but my if statement found an error, the Validator would fail

thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire