Skip to content

Instantly share code, notes, and snippets.

@alexalannunes
Created July 26, 2022 18:32
Show Gist options
  • Save alexalannunes/de21c7530d47c79c73aef254706e027d to your computer and use it in GitHub Desktop.
Save alexalannunes/de21c7530d47c79c73aef254706e027d to your computer and use it in GitHub Desktop.
validate cell of array matrix
var csv = [
["id", "nome", "cidade_id"],
[23, "alex", "pereiro"],
[23, "alex", "pereiro"],
[23, "alex", 3],
]
const col= csv[0][2] // cidade_id
const cel = typeof csv[3][2]; // 3
const columns ={
"id": "string",
"nome": "string",
"cidade_id": "number"
}
columns[col] === cel; // number === number
columns;
// true
// {
// id: 'string',
// nome: 'string',
// cidade_id: 'number'
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment