Checks if the input is a formula and validates that all variables mentioned in the formula exist either in the provided data frame or in the environment. This is a lightweight validation function that should be called early in functions that accept formula syntax.
validate_formula(
formula,
data = NULL,
func_name = "function",
calling_env = parent.frame()
)Returns NULL invisibly. Stops with an error if validation fails.
A potential formula object to validate (can be any object).
An optional data frame containing the variables.
Character string. Name of the calling function (for error messages).
The environment in which to look for variables if data is not provided. Defaults to parent.frame().