def validate(self, ba):
<EOL>l = len(ba)<EOL>i = <NUM_LIT:0><EOL>state = self._state<EOL>while i < l:<EOL><INDENT>state = ord(<EOL>UTF8VALIDATOR_DFA_S[<EOL><NUM_LIT> + (state << <NUM_LIT:4>) + ord(UTF8VALIDATOR_DFA_S[ord(ba[i])])<EOL>]<EOL>)<EOL>if state == UTF8_REJECT:<EOL><INDENT>self._state = state<EOL>self._index += i<EOL>return False, False, i, self._index<EOL><DEDENT>i += <NUM_LIT:1><EOL><DEDENT>self._state = state<EOL>self._index += l<EOL>return True, state == UTF8_ACCEPT, l, self._index<EOL>
Incrementally validate a chunk of bytes provided as string.
Will return a quad ``(valid?, endsOnCodePoint?, currentIndex, totalIndex)``.
As soon as an octet is encountered which renders the octet sequence
invalid, a quad with ``valid? == False`` is returned. ``currentIndex`` returns
the index within the currently consumed chunk, and ``totalIndex`` the
index within the total consumed sequence that was the point of bail out.
When ``valid? == True``, currentIndex will be ``len(ba)`` and ``totalIndex`` the
total amount of consumed bytes.