public function validate(LaravelExcelReader $reader) { if (!$this->rules()) { return; } $count = 0; $reader->each(function (CellCollection $row) use(&$count) { if ($count > 0 || !$this->hasHeader()) { $mapped = []; try { $mapped = $this->map($row->all()); } catch (Exception $e) { $this->log->log('Validator mapping failed'); throw $e; } $validator = Validator::make($mapped, $this->rules(), []); if ($validator->fails()) { throw new Exception('Invalid row #' . $count . ': ' . implode(', ', $validator->messages()->all())); } } $count++; }); }