View source: R/assert_create.R
assert_create_chain | R Documentation |
Combine multiple assertion functions created by assert_create()
into a single assertion function with diverse failure modes and error messages.
assert_create_chain(...)
... |
assertion functions created by |
A single assertion function that calls each of the input functions in the order they are supplied.
# Create an assertion function that checks for both positive integers and even values
assert_string <- assert_create_chain(
assert_create(is.character, '{{arg_name}} must be a character'),
assert_create(function(x){{ length(x)==1 }}, '{{arg_name}} must be length 1')
)
# Use the assertion function to check a valid value
assert_string("String")
# Use the assertion function to check an invalid value
try({
assert_string(3)
# Output: Error: '3' must be a character
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.