Add validation of term regex

Both interfaces will return an error if invalid according to re:compile.
Notice that the interface compiles the regular expression, but the
compiled version is not used in the query: each node will recompile it
upon receiving it to avoid incompatibilities in a mixed cluster, where
the representation of the compiled regular expression might be
different.