
Validate the value an asynchronous function resolves to
Source:R/async_validate.R
async_validate_return.RdAsynchronous version of validate_return(), for functions that return a
promise. The validator checks the resolved value, not
the promise. If it fails, the promise returned by the decorated function
rejects with a fnware_validation_error. Rejections from the wrapped
function carry on unchanged. Needs the promises package.
Arguments
- validator
For
validate_return(), a validator for the returned value.
Details
Arguments are available at call time, so validate_args() works for
asynchronous functions as it is.
Examples
if (FALSE) { # \dontrun{
f := async_validate_return(is.character) %@%
function() promises::promise_resolve(1)
promises::catch(f(), function(err) cat(conditionMessage(err), "\n"))
while (!later::loop_empty()) later::run_now(0.05)
} # }