frictionlessdata / tableschema-js

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

Questions about header validation #145

Closed am17torres closed 5 years ago

am17torres commented 6 years ago

I have two questions about header validation:

1) Did you intend for header order to matter? In table.js

if (!isEqual(this.headers, this.schema.fieldNames)) {
            const error = new TableSchemaError(
              'The column header names do not match the field names in the schema')
> const _ = require('lodash')
> const a = ['first','second']
> const b = ['second','first']
> _.isEqual(a,b)
false

Is there any reason not to sort them before comparing that the lists are equal?

2) I think this means that a field marked with the constraint required: false still needs to be present in the .csv even if it's missing for all rows. I think this logic needs to be a bit more complex to handle the case where fields are optional in the schema and not present in the content.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

roll commented 5 years ago

Sorry, this question was missed.

This is an implementation of https://frictionlessdata.io/specs/tabular-data-resource/ where the data columns MUST follow the order of the fields.

There are other tools like https://github.com/frictionlessdata/goodtables-py which is more flexible (e.g. the re-ordering headers option etc)