Data-Liberation-Front / csvlint.rb

The gem behind http://csvlint.io
MIT License
283 stars 86 forks source link

Constraints are applied even if the column is nullable #213

Open mtsmfm opened 6 years ago

mtsmfm commented 6 years ago

Constraints are applied even if the column is nullable. Is it intentional?

app@b1823785e3ed:/app$ cat foo.csv
id,foo
1,
2,x
3,xx
app@b1823785e3ed:/app$ cat foo.json
{
  "fields": [
    {
      "name": "id",
      "type": "integer",
      "constraints": {
        "required": true
      }
    },
    {
      "name": "foo",
      "type": "string",
      "constraints": {
        "required": false,
        "minLength": 2
      }
    }
  ]
}
app@b1823785e3ed:/app$ bundle exec bin/csvlint foo.csv --schema=foo.json
NOTE: Csvlint::Schema.load_from_json is deprecated; use load_from_uri instead. It will be removed on or after 2018-01-01.
Csvlint::Schema.load_from_json called from /app/lib/csvlint/cli.rb:59.
.!!.
foo.csv is INVALID
1. foo: min_length. Row: 2,2.
2. foo: min_length. Row: 3,2. x

Expected Behaviour

foo.csv is VALID

Current Behaviour (for problems)

foo.csv is INVALID
1. foo: min_length. Row: 2,2.
2. foo: min_length. Row: 3,2. x

Your Environment