csvlint.rb icon indicating copy to clipboard operation
csvlint.rb copied to clipboard

Spurious invalid header error

Open opoudjis opened this issue 10 years ago • 1 comments

In column.rb you have

      def validate_header(header, strict)
        reset
        if strict || @titles
          valid_headers = @titles ? @titles.map{ |l,v| v if Column.languages_match(l, lang) }.flatten : []
          unless valid_headers.include? header
            if strict
              build_errors(:invalid_header, :schema, 1, @number, header, @titles)

Now, if @titles is not passed into the Columns class (and as far as I can tell, it is not), then valid_headers will be empty. In that case, all headers will fail the validation test.

What you actually want is

      unless valid_headers.empty? or valid_headers.include? header

opoudjis avatar Jan 29 '16 15:01 opoudjis

See See https://github.com/nsip/csvlint.rb for patch

opoudjis avatar Jan 31 '16 09:01 opoudjis