class Zizia::CsvFormatValidator

A validator for correctly formatted CSV.

@example

parser = Parser.new(file: File.open('path/to/my.csv'))

CsvFormatValidator.new.validate(parser: parser)

@see ruby-doc.org/stdlib-2.0.0/libdoc/csv/rdoc/CSV/MalformedCSVError.html

Public Instance Methods

run_validation(parser:, **) click to toggle source

@private

@see Validator#validate

# File lib/zizia/validators/csv_format_validator.rb, line 18
def run_validation(parser:, **)
  return [] if CSV.parse(parser.file.read)
rescue CSV::MalformedCSVError => e
  [Error.new(self.class, e.class, e.message)]
ensure
  parser.file.rewind
end