Learn R Programming

whapi (version 0.0.2)

whapi_validate_list_sections: Validate list_sections for Whapi LIST interactive messages

Description

Internal helper that validates the structure of list_sections used in Whapi LIST messages. Each section must provide a non-empty title and a non-empty rows list. Each row must provide non-empty id and title. The description field is optional.

Usage

whapi_validate_list_sections(list_sections, verbose = TRUE, trim = TRUE)

Value

The (possibly trimmed) list_sections object, invisibly unchanged in shape.

Arguments

list_sections

A list of sections; each section is a named list with title (character) and rows (list of row objects).

verbose

Logical (default TRUE). If TRUE, prints progress messages via cli.

trim

Logical (default TRUE). If TRUE, trims whitespace from section$title, row$title, and row$id before validating.

Details

Expected structure:

list_sections <- list(
  list(
    title = "Section title",
    rows = list(
      list(id = "r1", title = "Row title", description = "Optional"),
      ...
    )
  ),
  ...
)

This function performs lightweight validation and (optionally) trims whitespace from titles and ids to avoid subtle formatting issues.

See Also

Helpers for interactive payloads such as whapi_coerce_buttons_base(), whapi_coerce_buttons_quick(), and whapi_coerce_buttons_mixed().

Examples

Run this code
sections <- list(
  list(
    title = "Burgers",
    rows = list(
      list(id = "r1", title = "Plain",  description = "No cheese, no sauce"),
      list(id = "r2", title = "Cheese", description = "With melted cheese")
    )
  )
)
whapi_validate_list_sections(sections)

Run the code above in your browser using DataLab