2 * @typedef {string} cell
6 * @typedef {cell[]} validateData~column
10 * @param {column[]} rows
11 * @returns {undefined}
13 export default (rows) => {
14 if (!Array.isArray(rows)) {
15 throw new TypeError('Table data must be an array.');
18 if (rows.length === 0) {
19 throw new Error('Table must define at least one row.');
22 if (rows[0].length === 0) {
23 throw new Error('Table must define at least one column.');
26 const columnNumber = rows[0].length;
28 for (const cells of rows) {
29 if (!Array.isArray(cells)) {
30 throw new TypeError('Table row data must be an array.');
33 if (cells.length !== columnNumber) {
34 throw new Error('Table must have a consistent number of cells.');
37 for (const cell of cells) {
38 // eslint-disable-next-line no-control-regex
39 if (/[\u0001-\u0006\u0008\u0009\u000B-\u001A]/.test(cell)) {
40 throw new Error('Table data must not contain control characters.');