def validate_row_lengths(fields,  # type: Sequence[FieldSpec]
                         data  # type: Sequence[Sequence[str]]
                         ):
    # type: (...) -> None
    """ Validate the `data` row lengths according to the specification
        in `fields`.

        :param fields: The `FieldSpec` objects forming the
            specification.
        :param data: The rows to check.
        :raises FormatError: When the number of entries in a row does
            not match expectation.
    """
    for i, row in enumerate(data):
        if len(fields) != len(row):
            msg = 'Row {} has {} entries when {} are expected.'.format(
                i, len(row), len(fields))
            raise FormatError(msg)