Closed iSimar closed 4 years ago
@iSimar
We can use field.constraints
:
schema.getField('name').constraints.maxLength
field.constraints.maxLength
@roll: Thanks for your answer however the maxLength
property is not present in the constraints
object from the Field
.
In fact, I get:
field.constraints
to be an empty object {}
. Do I need to pass any special parameter in table.infer
so that the object constraints
is non-empty?
@sebasalvarado No, it doesn't infer constraints. We have to set constraints manually in this case. I thought your descriptor had already had it
@roll is there a roadmap to infer constraints?
@iSimar I'm not sure. Could you please check in the official Gitter channel - https://gitter.im/frictionlessdata/chat
The recommended way is to wrap the library functionality to achieve the goal e.g.
const table = await Table.load('data.csv')
const headers = table.headers
const sample = await table.read({limit: 100})
const schema = await infer(sample, {headers})
// analyze sample and add the needed constraints to the schema
I'm closing as in a general case, inferring constraints is not possible or expected by the majority of users
Just like how you receive the type of a column, is there is a way to get the max length of characters for values in a column?