Input Validation with CodeMirror 6

Hi,
Is it possible (or even a good idea) to use codemirror as an input validation tool?
My use case is to highlight errors a user makes while typing (invalid boolean operations), and show a tooltip with the error that matched.

As far as I understand, I can define tokens using regex in a LezerLanguage, and if those tokens match I should be able to highlight the errors with the EditorView and a HighlightStyle.

Is there any example on how to do that? I’m currently struggling with using codemirror (v6) in Vue3.js and I could not really see anything similar in the Examples.

The syntax tree produced by a language written as a Lezer parser will contain error nodes at the points where the parser couldn’t match the document to the grammar. You could ‘validate’ the document by searching for such nodes, and, indeed, show markers where they occur (though they may be zero-length when the parser ‘inserted’ a phantom token to correct the error, so just styling the text they cover isn’t enough).