favr 2.0.0
CRAN release: 2026-08-20
Refactor of the package to focus on function argument validation through “check” functions that throw an error if validation fails and return NULL (or occasionally the input) invisibly if validation succeeds.
New Features
General Validation
-
abortif()andabortifnot()functions to check conditions and error if a condition isTRUEorFALSE, respectively. -
check()function to check conditions using tidy eval and error if a condition isTRUE. -
check_with()function to check conditions in a data-masked context and error if a condition isTRUE. -
walk_check()function to walk a predicate over a vector and error if any element fails the check.
Type and Class Validation
-
check_inherits()andcheck_class()functions to check the class of an object and error if it does not inherit from a specified class.
Type Validation
check_list(),check_atomic(),check_vector(),check_integer(),check_double(),check_numeric(),check_character(),check_logical(),check_complex(),check_raw(),check_bytes()andcheck_null()functions to check the type of an object and error if it does not match the specified type.check_scalar_list(),check_scalar_atomic(),check_scalar_vector(),check_scalar_integer(),check_scalar_double(),check_scalar_numeric(),check_scalar_character(),check_scalar_logical(),check_scalar_complex(),check_scalar_raw()andcheck_scalar_bytes()functions to check if an object is a scalar of the specified type and error if it is not.check_array(),check_matrix()andcheck_table()functions to check if an object is an array, matrix, or table, respectively, and error if it is not.
OOP Type Validation
-
check_s3(),check_s4(),check_s7()andcheck_r6()functions to check if an object is of the specified OOP type and error if it is not.
S3 Type Validation
check_factor(),check_ordered(),check_date(),check_posixct()andcheck_posixlt()functions to check if an object is of the specified S3 vector type and error if it is not.check_data_frame(),check_tibble(),check_data_table()andcheck_tidytable()functions to check if an object is of the specified S3 data frame type and error if it is not.check_vctr()andcheck_list_of()functions to check if an object is of the specifiedvctrsS3 type and error if it is not.s3_vec_check()ands3_df_check()functions for developers to create their own S3 type checks for vector and data frame types, respectively.
Check Modifiers
bare()modifier to check for bare objects (i.e. objects with no class attribute) in the type check functions, or bare S3 objects (where the expected S3 class is first in the class attribute vector) in the S3 type check functions.at_least(),at_most(), andin_range()modifiers to check for ranges in length/number of rows/number of columns.
Scalar Value Validation
-
check_true(),check_false(),check_bool()andcheck_string()functions to check if an object is a scalar of the specified type and value and error if it is not.
Forbidden Values Validation
-
check_no_na(),check_finite(),check_unique()andcheck_nzchar()functions to check for the presence of forbidden values and error if found.
Property Validation
check_length(),check_nrow(),check_ncol(),check_size()andcheck_non_empty()functions to check for an expected length/size of an object and error if it is not.check_named()function to check the names of an object and error if the object is not named or (optionally) if the names contain empty or duplicated elements.
File and Directory Validation
-
check_dir()andcheck_file()functions to check if a directory or file exists and error if it does not. -
check_ext()function to check the file extension of a file/path and error if it does not match the specified extensions.
Questioning
Removed the online documentation for enforce(), schema(), add_to_schema(), enforce_schema(), and the associated casting and recycling helpers (cast(), lossy(), recycle() and coerce()).
Soft-Deprecated
-
abort_if_not()should be replaced withabortifnot()orcheck(). -
cast_if_not()andrecycle_if_not()should be replaced with theirvctrsequivalents,vctrs::vec_cast()andvctrs::vec_recycle(), respectively. - All
are_*()functions and thehave_names()function - their use cases were limited and are easily replicated usingbase::vapply()and the associated predicate function.
Bug Fixes
- Fixed a bug where
are_scalar_integerish()would immediately error due to an erroneous.nargument.
