Recent Releases of valaddin
valaddin - v1.0.0
With this release, valaddin is frozen. The next iteration of valaddin is the rong package. Future releases of valaddin itself will only fix bugs.
Maintenance of the package has been substantially simplified by dropping purrr as a dependency (#57, #58).
The lazyeval requirement has been bumped to 0.2.1, to get functionality that was provisionally provided by future.R. The lazyeval package, which is itself frozen, is now the sole dependency.
Breaking changes
vld_singleton()now only checks whether an object has length 1, atomic or not.Bare-vector checkers (e.g.,
vld_bare_logical()) have been removed.
- R
Published by egnha over 7 years ago
valaddin -
The main purpose of this release is to repair minor breakages introduced by the recent release of purrr 0.2.3.
NB — This will likely be the last release before 0.3.0, which introduces a re-conceived API that supports programmable error messages and tidyverse-style quasiquotation.
Other changes include:
New operator for input validation
- A new operator
%checkin%provides an alternative way to write checks next to function headers (#21, suggested by @MilkWasABadChoice). For example, writinglist(~is.numeric, ~{. > 0}) %checkin% function(a, b) a + bis equivalent to writingfirmly(~is.numeric, ~{. > 0}, .f = function(a, b) a + b). Using the%checkin%operator is the recommended way to apply input validation in scripts and packages.
New functions
The localized check makers
vld_any()andvld_all()correspond to the base predicatesany()andall().To match naive expectations, a localized check maker
vld_closure()is introduced to validate closures, i.e., non-primitive functions, whilevld_function()has been redefined to validate functions in general, i.e., it corresponds to the base R predicateis.function(#18).
Minor improvements
dplyr is no longer required, substantially lightening valaddin's dependencies
Since
loosely()is typically used to obviate the overhead of input validation, calling it should itself impose as little overhead as possible (#28). Therefore,loosely()has been streamlined: it no longer checks its inputs. Calling it is now on par with callingfirm_core().firmly()gets a new option,.error_class, that enables you to customize the subclass of the error object that is signaled when an input validation error occurs (#25).Reduced use of assignment, subsetting and warning suppression speeds up
firmlyto within an order of magnitude of the speed of input validation usingstopifnot.The environment of check formulae generated by the
vld_*()check makers is the package namespace environment. (Previously, such check formulae got their own environment, though there was no need for such separation.)Printing of functions (i.e., those underlying firmly applied functions and predicate functions of check-formula makers) is normalized to eliminate spurious indentation (#23).
Minor edits to vignette.
Bug fixes
Validation error messages now display all arguments with specified or default value (#33). Previously, only specified arguments were shown, even when the source of a validation failure was an invalid default value.
When evaluating input-validation expressions, the lexical scope of promises is now completely isolated from the lexical scope of (check formula) predicate functions (#32). With this fix,
firmly()and%checkin%are now safe to use in package namespace environments. Previously, it was possible for a predicate function to be hijacked by a homonymous promise, or for an input validation to fail for an argument with default value, if that default value was inaccessible from the parent frame.If a formal argument happened to coincide with the name of an object in the input validation procedure (
valaddin:::validating_closure()), that formal argument could be inadvertently invoked in place of that object. This bug has been fixed by referencing bindings in the enclosing environment. (However, doing something truly ill-advised, such as duping a base R function, will still go unsupervised.)
Deprecated
- The
.quietargument has been dropped fromloosely(). (If desired, the behavior of that option can be replicated by signaling an appropriate warning prior to callingloosely().)
- R
Published by egnha almost 9 years ago