<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def validate_row_lengths(fields, # type: Sequence[FieldSpec] data # type: Sequence[Sequence[str]] ):
 """ 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)