Skip to content

Conversation

@kieranjmartin
Copy link

Resolves #514

Incorportating check_ard_structure into as_card proved to not be straight forwards as as_card is used throughout the code base to coerce objects into a card class that do not pass the checks in check_ard_structure.

For now at least I did the following

  1. check_ard_structure can either error or warn based on user input. I made a function to switch between these (I couldn't see any function which existed to do this already). Part of me wonders about allowing the user a bit more control over what it considers an error or a warning; they can switch off caring about the column order, and whether there is a methods entry, but maybe we could allow more in future. That said I think it's probably better as a binary switch for a change
  2. In as_card, there is now an argument for whether you want to check if a card follows this structure. At the moment this defaults to TRUE, but if you think this is too strong I could switch it to default FALSE. Doing that would be the most low impact change.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 15, 2025

✅ All contributors have signed the CLA
Posted by the CLA Assistant Lite bot.

@kieranjmartin
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

Comment on lines +80 to +83
# Check whether expected columns are present ---------------------------------



Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is missing something

.message_or_error(
"The following columns are expected to be list columns: {.val {not_a_lst_columns}}.",
error = error_on_fail,
envir = environment()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this needed if default is rlang::current_env()?

Comment on lines +47 to +48
return(out)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return(out)
out


# check in inputs ------------------------------------------------------------
check_class(x, cls = "data.frame")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
check_scalar_logical(check)

Comment on lines +14 to +16
expect_no_error(
check_ard_structure(data.frame(badname = 3))
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expect_no_error(
check_ard_structure(data.frame(badname = 3))
)
expect_no_error(
check_ard_structure(data.frame(badname = 3))
)

)
})


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Comment on lines +112 to +113
#' cards:::..warn_or_error("This will be a message", FALSE)
#' cards:::..warn_or_error("This will be an error", TRUE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be message_or_error right?


#' Message or error
#'
#' Either error or message depending on input
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#' Either error or message depending on input
#' Either error or message depending on input.

#' @param msg (scalar `character`)\cr
#' Error message
#' @param error (scalar `logical`)\cr
#' If this should produce an error or a warning. FALSE by default
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#' If this should produce an error or a warning. FALSE by default
#' If this should produce an error or a warning. FALSE by default

#' Environment to evaluate the glue expressions in passed in `cli::cli_abort(message)`.
#' Default is `rlang::current_env()`
#' @inheritParams cli::cli_abort
#' @return Invisible NULL
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure this is needed. Also it is internal

Comment on lines +124 to +125
return(invisible())

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return(invisible())

Maybe without this completely?


}


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Handle list columns

3 participants