The only real way of telling if a TeX or LaTeX expression is valid is to run TeX or LaTeX on it. So really, the only thing to do is to actually typeset it and check if it produced an error or not. There are several approaches to this. One is given in issue #2414
which gives the idea of how to use the formatError() function together with MathJax.tex2svgPromise() or MathJax.tex2chtmlPromise() to trap the errors. (Note that in v4.0.0-beta.x for any x from 1 to 6, you need to add MathJax.startup.promiseResolve() before the return statement if you are doing typesetting within the pageReady() function). This allows you to trap the error for the typesetting of a single expression. You can also use formatError() to process error for a whole page by not throwing an error but just reporting it. Note that jax.latex gives the LaTeX for the given error, and jax.parseOptions.mathItem is the MathItem that caused the error.
Another approach is given in issue #2992
The example there was used to replace the errant expression with a different message text, but you could use that idea to identify all the error-producing expressions within a page.