title: Per row validation while importing CSV file
body: <p>I'm Importing a CSV file to a livewire component and trying to run some validation for each row of the file but I'm having problems doing this. It seems that my validation is doing nothing.</p>
  <p>Here is how my Livewire component looks like:</p>
  <pre><code>namespace App\Http\Livewire\Modals;
  
  use Validator;
  use Livewire\Component;
  use App\Http\Traits\Csv;
  use App\Models\AccountUser;
  use Livewire\WithFileUploads;
  use Illuminate\Support\Facades\Auth;
  
  class ImportExtensions extends Component
  {
  
  use WithFileUploads;
  
  public $clientID;
  public $showModal = false;
  public $upload;
  public $columns;
  public $fieldColumnMap = [
      'first_name' =&gt; '',
      'last_name' =&gt; '',
      'email' =&gt; '',
      'password' =&gt; '',
      'extension' =&gt; '',
      'user_type' =&gt; '',
  ];
  
  protected $rules = [
          'fieldColumnMap.first_name' =&gt; 'required|max:255',
          'fieldColumnMap.last_name' =&gt; 'required|max:255',
          'fieldColumnMap.email' =&gt; 'required|max:255',
          'fieldColumnMap.password' =&gt; 'required|max:255',
          'fieldColumnMap.extension' =&gt; 'required|max:255',
          'fieldColumnMap.user_type' =&gt; 'required|max:255',
  ];
  
  protected $validationAttributes = [
      'fieldColumnMap.first_name' =&gt; 'First Name',
      'fieldColumnMap.last_name' =&gt; 'Last Name',
      'fieldColumnMap.email' =&gt; 'Email',
      'fieldColumnMap.password' =&gt; 'Password',
      'fieldColumnMap.extension' =&gt; 'Extension',
      'fieldColumnMap.user_type' =&gt; 'User Type',
  ];
  
  public function updatingUpload($value)
  {
      Validator::make(
          ['upload' =&gt; $value],
          ['upload' =&gt; 'required|mimes:txt,csv'],
      )-&gt;validate();
  }
  
  public function updatedUpload()
  {
      $this-&gt;columns = Csv::from($this-&gt;upload)-&gt;columns();
      $this-&gt;guessWhichColumnsMapToWhichFields();
  }
  
  public function import()
  {
      // Validate that you are importing any data
      $this-&gt;validate();
  
      $importCount = 0;
      Csv::from($this-&gt;upload)
      -&gt;eachRow( function ($row) use (&amp;$importCount){
          $eachRow = $this-&gt;extractFieldsFromRow($row);
  
          //Validate the data of each Row to make to make sure you don't import duplicate records   
          $this-&gt;validateOnly(collect($eachRow), [
              'fieldColumnMap.first_name' =&gt; 'required|max:255',
              'fieldColumnMap.last_name' =&gt; 'required|max:255',
              'fieldColumnMap.email' =&gt; 'required|max:255|email|unique:account_users, email',
              'fieldColumnMap.extension' =&gt; 'required|numeric|unique:account_users, extension',
              'fieldColumnMap.password' =&gt; 'required|max:255',
              'fieldColumnMap.user_type' =&gt; 'required|in:user,admin',
          ]);
  
          //If validation fails, it should skip the create extension part and run the next row
  
          //If validation pass, then create the Extension
          AccountUser::create([
              'user_id' =&gt; Auth::user()-&gt;id,
              'account_id' =&gt; $this-&gt;clientID,
              'first_name' =&gt; $eachRow['first_name'],
              'last_name' =&gt; $eachRow['last_name'],
              'email' =&gt; $eachRow['email'],
              'password' =&gt; $eachRow['password'],
              'extension' =&gt; $eachRow['extension'],
              'user_type' =&gt; $eachRow['user_type'],
          ]);
          $importCount++;
      });
      $this-&gt;reset();
      $this-&gt;emit('refreshExtensions');
      $this-&gt;notify('Successfully Imported '.$importCount.' Extensions');
  }
  </code></pre>
  <p>Also, how can I make so that if the validation fails it goes to the next row instead of trying to create the extension.</p>
  <p>Thanks.</p>