Skip to content

Commit

Permalink
Merge pull request #82 from theodi/feature-xsd-integer
Browse files Browse the repository at this point in the history
Support xsd:integer
  • Loading branch information
Floppy committed Mar 4, 2014
2 parents 9d3e1b9 + 8bd2103 commit 71787ef
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ Supported constraints:
Supported data types (this is still a work in progress):

* String -- `http://www.w3.org/2001/XMLSchema#string` (effectively a no-op)
* Integer -- `http://www.w3.org/2001/XMLSchema#int`
* Integer -- `http://www.w3.org/2001/XMLSchema#integer` or `http://www.w3.org/2001/XMLSchema#int`
* Float -- `http://www.w3.org/2001/XMLSchema#float`
* Double -- `http://www.w3.org/2001/XMLSchema#double`
* URI -- `http://www.w3.org/2001/XMLSchema#anyURI`
Expand Down
1 change: 1 addition & 0 deletions lib/csvlint/types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def self.included(base)
TYPE_VALIDATIONS = {
'http://www.w3.org/2001/XMLSchema#string' => SIMPLE_FORMATS['string'],
'http://www.w3.org/2001/XMLSchema#int' => lambda { |value, constraints| Integer value },
'http://www.w3.org/2001/XMLSchema#integer' => lambda { |value, constraints| Integer value },
'http://www.w3.org/2001/XMLSchema#float' => lambda { |value, constraints| Float value },
'http://www.w3.org/2001/XMLSchema#double' => lambda { |value, constraints| Float value },
'http://www.w3.org/2001/XMLSchema#anyURI' => SIMPLE_FORMATS['uri'],
Expand Down
6 changes: 6 additions & 0 deletions spec/field_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@
expect( field.validate_column("forty-two")).to be(false)
end

it "validates integers" do
field = Csvlint::Field.new("test", { "type" => "http://www.w3.org/2001/XMLSchema#integer" })
expect( field.validate_column("42")).to be(true)
expect( field.validate_column("forty-two")).to be(false)
end

it "validates floats" do
field = Csvlint::Field.new("test", { "type" => "http://www.w3.org/2001/XMLSchema#float" })
expect(field.validate_column("42.0")).to be(true)
Expand Down

0 comments on commit 71787ef

Please sign in to comment.