if (interactive()) {
library(surveydown)
# Define a server with custom stop conditions
server <- function(input, output, session) {
sd_stop_if(
# Stop if zip code is not exactly 5 digits
nchar(input$zip) != 5 ~ "Zip code must be 5 digits",
# Stop if year of birth is before 1900
as.numeric(input$yob) < 1900 ~ "Year of birth must be after 1900",
# Stop if phone number is not exactly 10 digits
nchar(input$phone) != 10 ~ "Phone number must be 10 digits"
)
sd_server()
}
}
Run the code above in your browser using DataLab