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

General functionality for handling validation in the app #1322

Open
pawelru opened this issue Aug 14, 2024 · 0 comments
Open

General functionality for handling validation in the app #1322

pawelru opened this issue Aug 14, 2024 · 0 comments
Labels

Comments

@pawelru
Copy link
Contributor

pawelru commented Aug 14, 2024

(please note that the below is just a rough design - feel free to adapt if needed)

  • module_validate_xyz() - a shiny module executing validation:
    • srv_validate_xyz(x) - it does the following:
       check_1 <- module_check_foo(x, ...)
       check_2 <- module_check_bar(x, ...)
       check_3 <- module_check_baz(x, ...)
       ...
       checks <- list(check_1, check_2, check_3, ...)
       r_validate <- reactive({
         for (check in checks) {
           validate(need(check()$isEmpty(), check$getMessages()))
         }
         x()
       })
       output$errors <- renderUI({
         r_validate()
         NULL
       })
       x
      
    • ui_validate_xyz() - display error message:
       tagList(
         uiOutput(NS(id, "errors"))
       )
      
      • we might assign a dedicated CSS class and apply custom styling of that element.
    • The goal is to allow nesting calls of validate module from another validate module
  • module_check_xyz() - a shiny module executing checks:
  • check_xyz() - for custom checks - only if needed, function returning TRUE if ok else error message (similar to checkmate)
  • test_xyz() - for custom checks - only if needed, function returning boolean (similar to checkmate)

Extra:
I do expect quite a few module_check_xyz() functions, e.g. module_check_reactive(), module_check_tryerror(), module_check_shinysilenterror(), module_check_qenverror. Instead of exporting a lot of objects, we might create a factory to create them dynamically if needed. (or both?)

The goals it to have a functionality that is:

  • testable
  • extendable - e.g. one validate module calling another validate module
  • returning consistent validation errors

The use cases:

  • teal:::srv_validate_reactive_teal_data
  • teal modules (I assume this is going to be exported)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants