
Check that a hypothesis string uses only model parameters and arithmetic
Source:R/utils-safe-code.R
is_safe_hypothesis.Rdbrms::hypothesis() evaluates its string as R code, so any function call
typed into a hypothesis box runs on the server. This check parses each
side of a single =, ==, <, or > relation and accepts only
parameter names, numeric constants, and the operators + - * / ^ ( :.
Examples
is_safe_hypothesis("level_AB > 0", c("b_Intercept", "b_level_AB"))
#> [1] TRUE
is_safe_hypothesis("level_AB*0 + q() = 0", "b_level_AB")
#> [1] FALSE