frictionlessdata / tableschema-js

A JavaScript library for working with Table Schema.
http://frictionlessdata.io/
MIT License
82 stars 27 forks source link

Schema.castRow invalid type errors #138

Closed AcckiyGerman closed 4 years ago

AcckiyGerman commented 6 years ago

Bug reproducing code: https://runkit.com/acckiygerman/5a9fa1b746ffd30012332a8e

const {Schema} = require('tableschema')

const schema = await Schema.load({
    fields: [
        {name: "time", type: "time", format: "any"},
        {name: "datetime", type: "datetime", format: "any"}
    ]
})

try{
    await schema.castRow(['00:01',  '2018/01/02T00:00:00'])
} catch (error){
    console.log(error.errors[0])
    console.log(error.errors[1])
}

Output:

TableSchemaError: The value "00:01" in column "time" is not type "time" and format "any"
TableSchemaError: The value "2018/01/02T00:00:00" in column "datetime" is not type "datetime" and format "any"

'00:01' is not a time value? This is definitely incorrect. '2018/01/02T00:00:00' also seems like a correct datetime to me.

Also the python version of Tableschema could casts this values, as it should be.

Expected behavior

AcckiyGerman commented 6 years ago

Found here: https://github.com/datahq/datahub-qa/issues/68

roll commented 4 years ago

00:01 is going to be fixed in #171 2018/01/02T00:00:00 is just not supported by moment.js. This any really relies on underlying libraries to guess the format so it's not cross-platform