Git Product home page Git Product logo

Comments (5)

mvarewyck avatar mvarewyck commented on July 24, 2024 2

@mkaranja I did something similar with the R package shinyFeedback

from shiny.

rpruim avatar rpruim commented on July 24, 2024

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)

from shiny.

maxheld83 avatar maxheld83 commented on July 24, 2024

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:

  • I like @rpruim's syntax, but I wonder whether integrating with some existing syntax/package for input validation (such as @mllg's checkmate) wouldn't be more elegant. --> mllg/checkmate#118.
  • Accepting more complicated validation tests inside inputText() may run the risk of duplicating validate() functionality, and might just confuse everyone more. Would it be possible to use render the validate() output to whichever inputx() created the offending ID. --> #1816

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

from shiny.

mkaranja avatar mkaranja commented on July 24, 2024

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.

from shiny.

cpsievert avatar cpsievert commented on July 24, 2024

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

from shiny.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.