inst/shiny-squid/source/utilities/test_input.R

# test if the input is valid
testInput  <- function(input, inputConf, isInteger, errorOutput, extraCondition=FALSE){ 
    
  validInput <- TRUE
  
  if(!is.numeric(input) || (isInteger & !testInteger(input)) || extraCondition){
    validInput <- FALSE
  }else{
    
    if(inputConf$min != "") if(input < inputConf$min) validInput <- FALSE
    if(inputConf$max != "") if(input > inputConf$max) validInput <- FALSE
  }
  
  if(errorOutput){
   if(!validInput){
    return(error_msg(inputConf$errorTxt))
   }else{
     return(NULL)
   }
  }
  
  return(validInput)  
}

Try the squid package in your browser

Any scripts or data that you put into this service are public.

squid documentation built on Jan. 22, 2022, 1:06 a.m.