Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork51
WIP: Modular validation inteal andteal_modules#1509
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
| } | ||
| .trigger_on_success<-function(data) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Moved from deleted file
| @@ -1,252 +0,0 @@ | |||
| #' Execute and validate `teal_data_module` | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
No longer used internally, deleting unless there is some use case
R/module_validate.R Outdated
| module_validate_teal_module<- module_validate_factory( | ||
| srv_module_check_previous_state_warn, | ||
| # Validate_error | ||
| srv_module_check_shinysilenterror, | ||
| srv_module_check_validation_error, | ||
| srv_module_check_condition, | ||
| srv_module_check_reactive, | ||
| srv_module_check_teal_data, | ||
| srv_module_check_datanames | ||
| ) | ||
| module_validate_datanames<- module_validate_factory( | ||
| srv_module_check_previous_state_warn, | ||
| srv_module_check_datanames | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
There are basically 2 types of data validation groups throughoutteal
We could reduce complexity of code and define the 2module_validate_xxx manually while still keeping with low-levelsrv_module_check_*** functions.
R/module_validate.R Outdated
| @@ -0,0 +1,325 @@ | |||
| #' Factory to build validate modules | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Example of list generated by factory:
#> > module_validate_datanames#> $uifunction(id) { div(id= NS(id,"validate_messages"),class="teal_validated",tags$div(class="messages", uiOutput(NS(id,"errors"))) ) }#> $serverfunction (id,x,show_warn= reactive(FALSE),message_warn="not defined",modules,stop_on_first=TRUE) {checkmate::assert_string(id) moduleServer(id,function(input,output,session) {collection<-list()collection<- append(collection, srv_module_check_previous_state_warn(x,show_warn,message_warn))collection<- append(collection, srv_module_check_datanames(id,x,modules))validate_r<- reactive({message_collection<- Reduce(function(u,v)if (isTRUE(v())|| is.null(v()))uelse append(u,list(v())),x=collection,init=list())message_collection })output$errors<- renderUI({error_class<- c("shiny.silent.error","validation","error","condition")if (length(validate_r())>0) { tagList(!!!lapply(validate_r()[1],function(.x) {html_class<-if (isTRUE(attr(.x[1],"is_warning"))|| isTRUE(attr(.x,"is_warning"))) {"teal-output-warning teal-output-condition" }else {"shiny-output-error teal-output-condition" }if (!checkmate::test_multi_class(.x, c("shiny.tag","shiny.tag.list"))) {html_class<- c(html_class,"prewrap-ws").x<- lapply(.x,tags$p) }tags$div(class=html_class,tags$div(.x)) })) } })x })}
…vel data is not teal_data
averissimo commentedApr 8, 2025
ℹ️ Updated example app |
averissimo commentedMay 9, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.

Uh oh!
There was an error while loading.Please reload this page.
🐻 WIP 🐻: Beware that code may break!!
Pull Request
Fixes#1322
Unified validation framework that allows to create re-usable validation modules for
tealframework as well as in modulesChanges description
srv_module_check_XXXXTRUEfor no problemmodule_validate_datanames$server)teal_data(pre-decorated) in the UI? #1421qenv.errorrequirement fromteal[Question]: qenv.error probably doesn't make sense anymore #1458Caveats
Error handling in parallelLogic should be very narrow to avoid repeated messages for the same underlying problem(such asshiny.silent.errorsvs.validationvs.generci conditions)stop_on_first = TRUEparameter for factory.Sample App to test errors