validateNoExtraTabularRows function

void validateNoExtraTabularRows(
  1. LineCursor cursor,
  2. int rowDepth,
  3. ArrayHeaderInfo header
)

Validates that there are no extra tabular rows beyond the expected count.

@param cursor The line cursor @param rowDepth The expected depth of rows @param header The array header info containing length and delimiter @throws RangeError if extra rows are found

Implementation

void validateNoExtraTabularRows(
    LineCursor cursor, int rowDepth, ArrayHeaderInfo header) {
  if (cursor.atEnd()) {
    return;
  }

  final nextLine = cursor.peek();
  if (nextLine != null &&
      nextLine.depth == rowDepth &&
      !nextLine.content.startsWith(listItemPrefix) &&
      _isDataRow(nextLine.content, header.delimiter)) {
    throw RangeError('Expected ${header.length} tabular rows, but found more');
  }
}