Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input validation #33

Closed
jcheng5 opened this issue Nov 9, 2012 · 5 comments
Closed

Input validation #33

jcheng5 opened this issue Nov 9, 2012 · 5 comments

Comments

@jcheng5
Copy link
Member

jcheng5 commented Nov 9, 2012

Need to give developers a way to specify what values are valid, at least for text boxes.

@rpruim
Copy link

rpruim commented Nov 21, 2012

perhaps an argument that takes a function that evaluates to TRUE or FALSE. Some frequent validity checks could be provided in the shiny package as utility functions, and special cases could be created by users on the fly:

is.positive <- function(x) {x > 0}
numericInput("number", "Positive Number:", 42, valid=is.positive)

@maxheld83
Copy link

maxheld83 commented Aug 15, 2017

not sure about the bigger scheme of things, but I was hoping some feature like this would exist.

My use case is where I might want to run some simple validation tests, such as:

  • provided string as a valid R object name
  • arbitrary regex

I'm aware of the validate(need()) way of doing things, but this perhaps has some shortcomings:

  1. it may sometimes be more intuitive to place some of these input validations right inside the textInput() call, especially when it's something simple such as accept only letters, no numbers.
  2. the validate(need()) errors are sometimes displayed multiple times, if some reactive object is part of several output objects – that makes strictly speaking sense, but just freaks users out.
  3. a similar problem arises for the UI/UX: input validation via validate() is customarily displayed in whatever output object is affected by some unacceptable input. This is a bit weird/distracting for users, who may expect such a message at the place where they need to make changes, say, by highlighting the textInput() entry field in red or whatever.

I know that I could (probably) build this by hand, using additional render*() output calls right next to the textInput() calls, but this would seem to add a lot of cruft to my code, and perhaps muddy intent. (I'm not really render*()ing any output, I'm just complaining about an input).

Anyway, I was hoping this would be possible outside the box, but I'm too naive a user to know how/if/where this should be done.

Am I making sense?

Other thoughts / caveats:

This may also be interesting to @bborgesr and/or revelant to #1656.

@mkaranja
Copy link

mkaranja commented Jan 3, 2018

Hi all,
So I need to validate email address textInput() and immediately tell the user to proceed by use of a check icon or show a warning to supply the right email address if not valid. I know how validate(need()) works but it's not suitable here.
Supporting @maxheld83 question, has anyone found a way to do this?
Thank you.

@mvarewyck
Copy link

@mkaranja I did something similar with the R package shinyFeedback

@cpsievert
Copy link
Collaborator

Closing since we now have https://github.com/rstudio/shinyvalidate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants