This is a continuation of a discussion on Twitter (see https://twitter.com/hadleywickham/status/1275426462447792130?s=20 and previous tweets).
In brief, what is the preferred mode of running validation checks on input variables in Shiny?
An example below:
# need + validate -----------------------------------------------------------
validate(
need(
check_mzr_object(ms_object$mzr_connection),
"Wasn't able to connect to MS file"
)
)
validate(
need(!is.null(input$ppm_input), "ppm_input must not be null"),
need(input$ppm_input > 0L, "ppm_input must be > 0")
)
# if + validate -----------------------------------------------------------
if (!check_mzr_object(ms_object$mzr_connection)) {
validate("Wasn't able to connect to MS file")
}
if (is.null(input$ppm_input)) {
validate("ppm_input must not be null")
} else if (input$ppm_input <= 0L) {
validate("ppm_input must be > 0")
}