Capture a warning about the validation process. Unlike check results (success/failure/error), validation warnings are informational messages about the validation process itself rather than validation outcomes.
Usage
capture_validation_warning(msg, where = NULL, call = rlang::caller_call(), ...)Arguments
- msg
Character string. The warning message. Accepts text that can be interpreted and formatted by
cli::format_inline().- where
Optional. Character string indicating the location or context of the warning (e.g., file path,
"hub-config"). Used as metadata.- call
The defused call of the function that generated the warning. Use to override default which uses the caller call. See rlang::stack for more details.
- ...
Additional named fields to include in the warning condition object. Useful for attaching structured data (e.g.,
config_files = c("tasks.json")).
Details
Validation warnings can be attached at two levels:
Validation-level: Stored as an attribute on
hub_validationsobjects, printed prominently by default.Check-level: Stored in a
warningsfield on individual check results, printed only whenverbose = TRUE.
Examples
# Simple warning
capture_validation_warning(
msg = "Configuration files were modified"
)
#> <warning/validation_warning>
#> Warning:
#> Configuration files were modified
# Warning with location and additional structured data
config_files <- c("tasks.json", "admin.json")
capture_validation_warning(
msg = "Config files modified: {.path {config_files}}",
where = "hub-config",
config_files = config_files
)
#> Error in "fun(..., .envir = .envir)": ! Could not evaluate cli `{}` expression: `config_files`.
#> Caused by error in `eval(expr, envir = envir)`:
#> ! object 'config_files' not found
