title: Triggering alerts with validate-need in Shiny?
body: <p>I am having difficulty triggering an alert in a Shiny app that I have created. The app itself is very simple, and displays one slider with numbers and a line plot. However, I would like for an alert to be triggered whenever the slider is set to a value above 5. Here is the code:</p>
  
  <p>UI</p>
  
  <pre><code>library(shiny)
  library(shinythemes)
  library(shinyBS)
  
  shinyUI(fluidPage(theme = shinytheme("superhero"),
                tags$head(
                  tags$style(HTML("
    .shiny-output-error-validation {
      color: green;
    }
  "))
                ),
  
  sidebarLayout(
  sidebarPanel(
    sliderInput("samplestat",
                "Value:",
                min = 1,
                max = 10,
                value = 1)
  ),
  
      mainPanel(
    h3("Graph", style = "font-family: 'Jura'; color: blue; font-size: 32px;"),
    HTML("&lt;p&gt;Graph&lt;/p&gt;"),
    plotOutput("LinePlot")
  )
  )
  ))
  </code></pre>
  
  <p>SERVER</p>
  
  <pre><code>library(shiny)
  library(ggplot2)
  library(scales)
  
  samplestat &lt;- function(input) {
  if (input &gt; 5) {
  "Choose another value. samplestat must be below 5!"
  } else if (input &lt; 4) {
  FALSE
  } else {
  NULL
  }
  }
  
  shinyServer(function(input, output) {
  
  data &lt;- reactive({
  validate(
    need(input$data != "", "Please select a value below 5")
  )
  get(input$data)
  })
  
  output$LinePlot &lt;- renderPlot({
  
  n=1:10
  samplestat &lt;- seq(min(n), max(n), length.out = input$samplestat)
  
  plot(samplestat, type = "o", col = 'blue', border = 'white', xlab="X Axis", ylab ="Y Axis")
  }
  
  )
  
  })
  </code></pre>
  
  <p>When I run this code, the line and slider displays, but I do not get any alert when I slide the slider to a value above 5. I am not sure if I am possibly using validate-need incorrectly, or whether I have overlooked something else.</p>