Validates that a parsed app.json
structure meets the requirements for a
Shinylive application. Checks for proper list structure, required fields,
and non-empty content. Provides detailed error messages when validation fails.
Value
Logical TRUE if validation passes. If validation fails, throws an error with detailed information about the validation failure using cli_abort().
Validation Rules
The function checks these requirements:
json_data
must be a listjson_data
must contain at least one elementEach element must be a list (representing a file)
Each file list must contain all required fields:
name
content
type
Error Messages
The function provides detailed error messages for these cases:
Not a list: "Expected a list or array of files"
Empty list: "File list is empty"
Invalid file entry: "Each entry must be a file object"
Missing fields: Lists specific missing required fields
Expected JSON Structure
The expected JSON structure is an array of objects, where each object represents a file in the application.
See also
find_shinylive_app_json()
which uses this validation
Examples
if (FALSE) { # \dontrun{
# Valid structure
valid_data <- list(
list(
name = "app.R",
content = "library(shiny)\n...",
type = "text"
),
list(
name = "data.csv",
content = "x,y\n1,2",
type = "text"
)
)
validate_app_json(valid_data) # Returns TRUE
# Invalid structures that will error:
validate_app_json(list()) # Empty list
validate_app_json(list(
list(name = "app.R") # Missing required fields
))
} # }