specify_lst: Create a specified list stabilizer function

View source: R/specify_lst.R

specify_lstR Documentation

Create a specified list stabilizer function

Description

specify_lst() creates a function that will call stabilize_lst() with the provided arguments. specify_list() is a synonym of specify_lst().

Usage

specify_lst(
  ...,
  .named = NULL,
  .unnamed = NULL,
  .allow_null = TRUE,
  .min_size = NULL,
  .max_size = NULL
)

specify_list(
  ...,
  .named = NULL,
  .unnamed = NULL,
  .allow_null = TRUE,
  .min_size = NULL,
  .max_size = NULL
)

Arguments

...

Named stabilizer functions, such as ⁠stabilize_*⁠ functions (stabilize_chr(), etc) or functions produced by ⁠specify_*()⁠ functions (specify_chr(), etc). Each name corresponds to a required element in .x, and the function is used to validate that element.

.named

A single stabilizer function, such as a ⁠stabilize_*⁠ function (stabilize_chr(), etc) or a function produced by a ⁠specify_*()⁠ function (specify_chr(), etc). This function is used to validate all named elements of .x that are not explicitly listed in .... If NULL (default), any extra named elements will cause an error.

.unnamed

A single stabilizer function, such as a ⁠stabilize_*⁠ function (stabilize_chr(), etc) or a function produced by a ⁠specify_*()⁠ function (specify_chr(), etc). This function is used to validate all unnamed elements of .x. If NULL (default), any unnamed elements will cause an error.

.allow_null

⁠(length-1 logical)⁠ Is NULL an acceptable value?

.min_size

⁠(length-1 integer)⁠ The minimum size of the object. Object size will be tested using vctrs::vec_size().

.max_size

⁠(length-1 integer)⁠ The maximum size of the object. Object size will be tested using vctrs::vec_size().

Value

A function of class "stbl_specified_fn" that calls stabilize_lst() with the provided arguments. The generated function will also accept ... for additional named element specifications to pass to stabilize_lst(). You can copy/paste the body of the resulting function if you want to provide additional context or functionality.

See Also

Other list functions: stabilize_lst(), stabilize_present(), to_lst()

Other specification functions: specify_chr(), specify_dbl(), specify_df(), specify_fct(), specify_int(), specify_lgl()

Examples

stabilize_config <- specify_lst(
  name = specify_chr_scalar(allow_na = FALSE),
  version = stabilize_int_scalar,
  debug = specify_lgl_scalar(allow_na = FALSE),
  .unnamed = stabilize_chr_scalar
)
stabilize_config(list(name = "myapp", version = 1L, debug = FALSE, "extra"))
try(
  stabilize_config(
    list(name = "myapp", version = 1L, debug = FALSE, c("a", "b"))
  )
)

stbl documentation built on April 4, 2026, 5:06 p.m.