danielvartan/prettycheck
✔️✨ Pretty Assertive Programming
prettycheck
Overview
Assertive programming doesn’t have to be ugly. If ultra-fast checks
aren’t your top priority, prettycheck is for you. This R package
provides a set of functions that produce pretty and informative error
messages, primarily using the cli package
from r-lib.
prettycheck adheres to tidyverse
principles and
seamlessly integrates with the tidyverse
ecosystem.
Need faster assertive programming? Try
checkmate. Since prettycheck
uses the same structural approach to checks, transitioning between
packages is straightforward. You can also use both packages together
without conflicts.
Installation
You can install prettycheck using the
remotes package:
remotes::install_github("danielvartan/prettycheck")Usage
Like checkmate, prettycheck
includes four family of functions: test_*(), check_*(),
assert_*(), and expect_*().
The test_*() functions return a logical flag; the check_*()
functions throw a warning message as a string if the condition is not
met; and the assert_*() and expect_*() functions throw an error if
the condition is not met. If the condition is met, check_*() returns a
logical flag; assert_*() and expect_*() functions return the input
object invisibly.
Here are some of the functions available:
assert_color():
Assert if an argument is a valid colorcheck_duration()
test_duration()assert_duration(): Check if an argument is a
Duration
objectcheck_hms()
test_hms()assert_hms(): Check if an argument is a
hmsobjectcheck_identical()
test_identical()assert_identical(): Check if multiple objects are
identicalcheck_interval()
test_interval()assert_interval(): Check if an argument is an
Interval
objectcheck_length()
test_length()assert_length(): Check if an argument has a specific
lengthcheck_period()
test_period()assert_period(): Check if an argument is a
Period
objectcheck_pick()
test_pick()assert_pick(): Check how many arguments were pickedcheck_posixt()
test_period()assert_period(): Check if an argument is aPOSIXt
objectcheck_temporal
test_temporal()assert_temporal(): Check if an argument is a
temporal object
Click here to see the
full list of functions.
License
prettycheck code is released under the MIT
license.
Contributing
Contributions are welcome, including bug reports. Take a moment to
review the Guidelines for
Contributing.
Become an prettycheck supporter!
Click here to make a
donation. Please indicate the prettycheck package in your donation
message.
