input_provided: Check whether an input value has been provided

View source: R/validator.R

input_providedR Documentation

Check whether an input value has been provided

Description

This function takes an input value and uses heuristics to guess whether it represents an "empty" input vs. one that the user has provided. This will vary by input type; for example, a shiny::textInput() is "" when empty, while a shiny::numericInput() is NA.

input_provided returns TRUE for all values except:

  • NULL

  • ""

  • An empty atomic vector or list

  • An atomic vector that contains only missing (NA) values

  • A character vector that contains only missing and/or "" values

  • An object of class "try-error"

  • A value that represents an unclicked shiny::actionButton()

Usage

input_provided(val)

Arguments

val

Values to test for availability in a Shiny context.

Details

This function is based on shiny::isTruthy() but tweaked here in shinyvalidate to change the treatment of FALSE values: isTruthy(FALSE) returns FALSE, but input_provided(FALSE) returns TRUE. This difference is motivated by shiny::checkboxInput(), where isTruthy() answers the question of "is the input present and checked" while input_provided is just "is the input present".

Value

A logical vector of length 1.


shinyvalidate documentation built on Oct. 4, 2023, 5:09 p.m.