Open samssann opened 3 years ago
The first input in the input-group is not validated on the ui level (but iv$is_valid() works properly).
app
library(shiny) library(shinyvalidate) is_dateish <- function(x) { tryCatch( expr = { as.Date(x) return(T) }, error = function(e) return(F) ) } shinyApp( ui = fluidPage( tags$div( id = "dmenu", class = "form-group shiny-input-container", tags$label(class = "control-label", `for` = "ifrom", "Date Range"), tags$div( id = "igroup", class = "input-group", tags$input(id = "ifrom", type = "text", class = "form-control", value = "", style = "text-align: center;", autocomplete="off"), tags$span( class = "input-group-addon input-group-prepend input-group-append", tags$span(class = "input-group-text", icon("arrow-right")) ), tags$input(id = "ito", type = "text", class = "form-control", value = "", style = "text-align: center;", autocomplete="off") ) ), verbatimTextOutput("is_valid") ), server = function(input, output, session) { iv <- InputValidator$new() iv$add_rule("ifrom", sv_required("'From' required")) iv$add_rule("ito", sv_required("'To' required")) iv$add_rule("ifrom", compose_rules( ~ if (!is_dateish(.)) "'From' must be a date")) iv$add_rule("ito", compose_rules( ~ if (!is_dateish(.)) "'To' must be a date")) iv$enable() output$is_valid <- renderPrint(iv$is_valid()) } )
session info
─ Session info ────────────────────────────────────────────────────────────────────────────────────────── setting value version R version 4.0.2 (2020-06-22) os Ubuntu 18.04.6 LTS system x86_64, linux-gnu ui RStudio language (EN) collate C.UTF-8 ctype C.UTF-8 tz Etc/UTC date 2021-09-21 ─ Packages ────────────────────────────────────────────────────────────────────────────────────────────── ! package * version date lib source P assertthat 0.2.1 2019-03-21 [?] CRAN (R 4.0.2) P bslib 0.2.4 2021-01-25 [?] CRAN (R 4.0.2) P cachem 1.0.6 2021-08-19 [?] CRAN (R 4.0.2) P cli 2.1.0 2020-10-12 [?] CRAN (R 4.0.2) P crayon 1.3.4 2017-09-16 [?] CRAN (R 4.0.2) P digest 0.6.25 2020-02-23 [?] CRAN (R 4.0.2) P ellipsis 0.3.1 2020-05-15 [?] CRAN (R 4.0.2) P fansi 0.4.1 2020-01-08 [?] CRAN (R 4.0.2) P fastmap 1.1.0 2021-01-25 [?] CRAN (R 4.0.2) P glue 1.4.2 2020-08-27 [?] CRAN (R 4.0.2) P htmltools 0.5.2 2021-08-25 [?] CRAN (R 4.0.2) P httpuv 1.5.4 2020-06-06 [?] CRAN (R 4.0.2) P jquerylib 0.1.3 2020-12-17 [?] CRAN (R 4.0.2) P jsonlite 1.7.1 2020-09-07 [?] CRAN (R 4.0.2) P later 1.1.0.1 2020-06-05 [?] CRAN (R 4.0.2) P lifecycle 0.2.0 2020-03-06 [?] CRAN (R 4.0.2) P magrittr 1.5 2014-11-22 [?] CRAN (R 4.0.2) P mime 0.9 2020-02-04 [?] CRAN (R 4.0.2) P promises 1.1.1 2020-06-09 [?] CRAN (R 4.0.2) P R6 2.4.1 2019-11-12 [?] CRAN (R 4.0.2) P Rcpp 1.0.5 2020-07-06 [?] CRAN (R 4.0.2) renv 0.12.0 2020-08-28 [1] CRAN (R 4.0.2) P rlang 0.4.11 2021-04-30 [?] CRAN (R 4.0.2) P rsconnect 0.8.16 2019-12-13 [?] CRAN (R 4.0.2) P rstudioapi 0.11 2020-02-07 [?] CRAN (R 4.0.2) P sass 0.3.1 2021-01-24 [?] CRAN (R 4.0.2) P sessioninfo 1.1.1 2018-11-05 [?] CRAN (R 4.0.2) P shiny * 1.6.0 2021-01-25 [?] CRAN (R 4.0.2) P shinyvalidate * 0.1.1 2021-06-29 [?] CRAN (R 4.0.2) P withr 2.2.0 2020-04-20 [?] CRAN (R 4.0.2) P xtable 1.8-4 2019-04-21 [?] CRAN (R 4.0.2)
The first input in the input-group is not validated on the ui level (but iv$is_valid() works properly).
app
session info