Comments (5)
@mkaranja I did something similar with the R package shinyFeedback
from shiny.
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.
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:
- 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. - 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. - 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 thetextInput()
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 duplicatingvalidate()
functionality, and might just confuse everyone more. Would it be possible to use render thevalidate()
output to whicheverinputx()
created the offending ID. --> #1816
This may also be interesting to @bborgesr and/or revelant to #1656.
from shiny.
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.
Closing since we now have https://github.com/rstudio/shinyvalidate
from shiny.
Related Issues (20)
- observeEvent does not trigger to changes in reactiveValues HOT 4
- Can't add another ExtendedTask while the one is running? HOT 1
- Busy indicator is only shown for 0.25s
- Progress bar properties cannot be cleared by setting `NULL`
- Bookmarking state on shinyapps.io & locally
- renderDataTable's lengthMenu content not showing
- shinyAppTemplate results in an error, likely from non namespaced `HTML()` call
- Documentation clarification: is `page_fluid()` now the default recommendation over `fluidPage()`? HOT 10
- runExample: new version that uses {bslib} no longer uses showcase mode by default, despite docs saying otherwise
- Shiny options that are supported in code but undocumented HOT 2
- Minor UI: slider inputs have a strange cursor type
- Example "06_tabsets" errors, requires {bslib} version higher than in DESCRIPTION
- session$setCurrentTheme(bs_theme): confusing behaviour+error message regarding version
- Documentation: devmode docs need some improvement
- Documentation: clarify how to use plugins in selectizeInput()
- Documentation: selectizeInput doesn't explain what selectize.js means
- Password managers try to autofill selectInput HOT 1
- `dateInput()`'s popup is incorrectly positioned when using bootstrap 5 top margin on parent container HOT 2
- Shiny 1.8.1.1 navbarPage doesn't work HOT 1
- Validate path as shiny app HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shiny.