Skip to content

Commit

Permalink
Merge pull request #70 from theodi/inconsistent-column-base
Browse files Browse the repository at this point in the history
Inconsistent column base
  • Loading branch information
Sam Pikesley committed Feb 18, 2014
2 parents d961b3e + 3c604d8 commit 58da0da
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/csvlint/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def validate_row(values, row=nil)

fields.each_with_index do |field,i|
value = values[i] || ""
result = field.validate_column(value, row, i)
result = field.validate_column(value, row, i+1)
@errors += fields[i].errors
@warnings += fields[i].warnings
end
Expand Down
5 changes: 5 additions & 0 deletions spec/schema_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
schema = Csvlint::Schema.new("http://example.org", [field, field2] )

expect( schema.validate_row( ["", "x"] ) ).to eql(false)
expect( schema.errors.size ).to eql(2)
expect( schema.errors.first.type).to eql(:missing_value)
expect( schema.errors.first.category).to eql(:schema)
expect( schema.errors.first.column).to eql(1)
expect( schema.validate_row( ["abc", "1234"] ) ).to eql(true)

end
Expand Down Expand Up @@ -87,6 +91,7 @@
expect( schema.warnings.size ).to eql(1)
expect( schema.warnings.first.type).to eql(:header_name)
expect( schema.warnings.first.content).to eql("wrong")
expect( schema.warnings.first.column).to eql(1)
expect( schema.warnings.first.category).to eql(:schema)

expect( schema.validate_header(["minimum", "Required"]) ).to eql(true)
Expand Down

0 comments on commit 58da0da

Please sign in to comment.