Skip to content

Commit 1c9978a

Browse files
authored
add the 2.0.0 changes (#9)
* change logo * favr rework
1 parent 3192c13 commit 1c9978a

136 files changed

Lines changed: 13813 additions & 1610 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

DESCRIPTION

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
Package: favr
22
Title: Function Argument Validation
3-
Version: 1.0.0.9000
3+
Version: 2.0.0
44
Authors@R:
55
person("Luke", "Jenkins", , "luke-jenkins-dev@outlook.com", role = c("aut", "cre", "cph"), comment = c(ORCID = "0000-0002-7206-7242"))
6-
Description: Validate function arguments succinctly with informative error messages and optional automatic type casting and size recycling. Enable schema-based assertions by attaching reusable rules to data.frame and list objects for use throughout workflows.
6+
Description: Validate function arguments succinctly with informative error messages.
77
License: MIT + file LICENSE
88
Encoding: UTF-8
99
Roxygen: list(markdown = TRUE)
10-
RoxygenNote: 7.3.2
1110
Imports:
1211
cli,
13-
rlang,
12+
lifecycle,
13+
rlang (>= 1.1.0),
1414
tidyselect,
1515
vctrs
1616
Suggests:
17-
testthat (>= 3.0.0)
17+
testthat (>= 3.0.0),
18+
withr
1819
Config/testthat/edition: 3
1920
URL: https://lj-jenkins.github.io/favr/, https://github.com/LJ-Jenkins/favr
2021
Depends:
2122
R (>= 4.1.0)
2223
BugReports: https://github.com/LJ-Jenkins/favr/issues
24+
Config/roxygen2/version: 8.0.0

NAMESPACE

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@ S3method(cnd_body,favr_error_size_arg)
2121
S3method(cnd_footer,favr_error_logi_returned)
2222
S3method(cnd_footer,favr_error_rhs_formula)
2323
S3method(cnd_header,favr_error)
24+
S3method(do_n_check,default)
25+
S3method(do_n_check,favr_at_least)
26+
S3method(do_n_check,favr_at_most)
27+
S3method(do_n_check,favr_in_range)
28+
S3method(do_ncol_check,default)
29+
S3method(do_ncol_check,favr_at_least)
30+
S3method(do_ncol_check,favr_at_most)
31+
S3method(do_ncol_check,favr_in_range)
32+
S3method(do_nrow_check,default)
33+
S3method(do_nrow_check,favr_at_least)
34+
S3method(do_nrow_check,favr_at_most)
35+
S3method(do_nrow_check,favr_in_range)
2436
S3method(enforce_schema,default)
2537
S3method(enforce_schema,with_schema)
2638
S3method(eval_formula_rhs,"favr:::arg")
@@ -33,6 +45,8 @@ S3method(schema,default)
3345
S3method(schema,list)
3446
export(abort_if)
3547
export(abort_if_not)
48+
export(abortif)
49+
export(abortifnot)
3650
export(add_to_schema)
3751
export(are_atomic)
3852
export(are_bare_atomic)
@@ -77,17 +91,76 @@ export(are_scalar_vector)
7791
export(are_string)
7892
export(are_true)
7993
export(are_vector)
94+
export(at_least)
95+
export(at_most)
96+
export(bare)
8097
export(cast)
8198
export(cast_if_not)
99+
export(check)
100+
export(check_array)
101+
export(check_atomic)
102+
export(check_bool)
103+
export(check_bytes)
104+
export(check_character)
105+
export(check_class)
106+
export(check_complex)
107+
export(check_data_frame)
108+
export(check_data_table)
109+
export(check_date)
110+
export(check_dir)
111+
export(check_double)
112+
export(check_ext)
113+
export(check_factor)
114+
export(check_false)
115+
export(check_file)
116+
export(check_finite)
117+
export(check_inherits)
118+
export(check_integer)
119+
export(check_list)
120+
export(check_list_of)
121+
export(check_logical)
122+
export(check_matrix)
123+
export(check_no_na)
124+
export(check_null)
125+
export(check_numeric)
126+
export(check_nzchar)
127+
export(check_ordered)
128+
export(check_posixct)
129+
export(check_posixlt)
130+
export(check_raw)
131+
export(check_scalar_atomic)
132+
export(check_scalar_bytes)
133+
export(check_scalar_character)
134+
export(check_scalar_complex)
135+
export(check_scalar_double)
136+
export(check_scalar_integer)
137+
export(check_scalar_list)
138+
export(check_scalar_logical)
139+
export(check_scalar_numeric)
140+
export(check_scalar_raw)
141+
export(check_scalar_vector)
142+
export(check_string)
143+
export(check_table)
144+
export(check_tibble)
145+
export(check_tidytable)
146+
export(check_true)
147+
export(check_vctr)
148+
export(check_vector)
149+
export(check_with)
82150
export(coerce)
83151
export(enforce)
84152
export(enforce_schema)
85153
export(have_names)
154+
export(in_range)
86155
export(lossy)
87156
export(recycle)
88157
export(recycle_if_not)
158+
export(s3_df_check)
159+
export(s3_vec_check)
89160
export(schema)
161+
export(walk_check)
90162
import(cli)
163+
import(lifecycle)
91164
import(rlang)
92165
import(tidyselect)
93166
import(vctrs)

NEWS.md

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,70 @@
1-
# favr (development version)
1+
# favr 2.0.0
2+
3+
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.
4+
5+
## New Features
6+
7+
### General Validation
8+
9+
* `abortif()` and `abortifnot()` functions to check conditions and error if a condition is `TRUE` or `FALSE`, respectively.
10+
* `check()` function to check conditions using tidy eval and error if a condition is `TRUE`.
11+
* `check_with()` function to check conditions in a data-masked context and error if a condition is `TRUE`.
12+
* `walk_check()` function to walk a predicate over a vector and error if any element fails the check.
13+
14+
### Type and Class Validation
15+
16+
* `check_inherits()` and `check_class()` functions to check the class of an object and error if it does not inherit from a specified class.
17+
18+
### Type Validation
19+
20+
* `check_list()`, `check_atomic()`, `check_vector()`, `check_integer()`, `check_double()`, `check_numeric()`, `check_character()`, `check_logical()`, `check_complex()`, `check_raw()`, `check_bytes()` and `check_null()` functions to check the type of an object and error if it does not match the specified type.
21+
22+
* `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()` and `check_scalar_bytes()` functions to check if an object is a scalar of the specified type and error if it is not.
23+
24+
* `check_array()`, `check_matrix()` and `check_table()` functions to check if an object is an array, matrix, or table, respectively, and error if it is not.
25+
26+
### S3 Type Validation
27+
28+
* `check_factor()`, `check_ordered()`, `check_date()`, `check_posixct()` and `check_posixlt()` functions to check if an object is of the specified S3 vector type and error if it is not.
29+
30+
* `check_data_frame()`, `check_tibble()`, `check_data_table()` and `check_tidytable()` functions to check if an object is of the specified S3 data frame type and error if it is not.
31+
32+
* `check_vctr()` and `check_list_of()` functions to check if an object is of the specified `vctrs` S3 type and error if it is not.
33+
34+
* `s3_vec_check()` and `s3_df_check()` functions for developers to create their own S3 type checks for vector and data frame types, respectively.
35+
36+
### Type Checking Modifiers
37+
38+
* `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.
39+
40+
* `at_least()`, `at_most()`, and `in_range()` modifiers to check for ranges in length/number of rows/number of columns.
41+
42+
### Scalar Value Validation
43+
44+
* `check_true()`, `check_false()`, `check_bool()` and `check_string()` functions to check if an object is a scalar of the specified type and value and error if it is not.
45+
46+
### Forbidden Values Validation
47+
48+
* `check_no_na()`, `check_finite()` and `check_nzchar()` functions to check for the presence of forbidden values and error if found.
49+
50+
### File and Directory Validation
51+
52+
* `check_dir()` and `check_file()` functions to check if a directory or file exists and error if it does not.
53+
* `check_ext()` function to check the file extension of a file/path and error if it does not match the specified extensions.
54+
55+
## Questioning
56+
57+
Removed the online documentation for `enforce()`, `schema()`, `add_to_schema()`, `enforce_schema()`, and the associated casting and recycling helpers (`cast()`, `lossy()`, `recycle()` and `coerce()`).
58+
59+
## Soft-Deprecated
60+
61+
* `abort_if_not()` should be replaced with `abortifnot()` or `check()`.
62+
* `cast_if_not()` and `recycle_if_not()` should be replaced with their `vctrs` equivalents, `vctrs::vec_cast()` and `vctrs::vec_recycle()`, respectively.
63+
* All `are_*()` functions and the `have_names()` function - their use cases were limited and are easily replicated using `base::vapply()` and the associated predicate function.
64+
65+
## Bug Fixes
66+
67+
* Fixed a bug where `are_scalar_integerish()` would immediately error due to an erroneous `.n` argument.
268

369
# favr 1.0.0
470

R/abort_if_not.r

Lines changed: 0 additions & 131 deletions
This file was deleted.

0 commit comments

Comments
 (0)