This function checks if the provided input options are valid based on a list of valid options.
It ensures that each option in inputOptions
matches the allowed types or values specified
in validOptions
. For options expecting numeric values, it checks if they fall within a
specified range. For boolean options, it checks if they are strictly TRUE
or FALSE
.
Arguments
- inputOptions
A list of options to validate. Each option's value is checked against the corresponding entry in
validOptions
.- validOptions
A list that specifies valid values or value types for each option. It can include specific values, types, or ranges for numeric options.
Value
If all input options are valid, the function returns
NULL
.If any input option is invalid, the function stops and signals an error with a message detailing the validation failures.
Examples
validOptions <- list(
algorithmType = c("gradient", "newton"),
enableLogging = c(TRUE, FALSE),
convergenceThreshold = list(type = "numeric", min = 1e-5, max = 0.1)
)
inputOptions <- list(
algorithmType = "gradient",
enableLogging = TRUE,
convergenceThreshold = 0.005
)
validateIsOption(inputOptions, validOptions)
#> NULL