Try to check if the pattern is valid.

see #289