Skip to contents

specify_one_of() creates a function that will call stabilize_one_of() with the provided specs. specify_one_of()'s function requires that exactly one of the provided specs succeeds.

Usage

specify_one_of(...)

Arguments

...

Unnamed stabilizer / to_* / specify_*() specs, forwarded to stabilize_one_of().

Value

A function of class "stbl_specified_fn" that calls stabilize_one_of() with the provided specs. The generated function will also accept ... for additional unnamed specs to pass to stabilize_one_of(). You can copy/paste the body of the resulting function if you want to provide additional context or functionality.

Examples

stabilize_int_xor_chr <- specify_one_of(stabilize_int, stabilize_chr)
stabilize_int_xor_chr("a")
#> [1] "a"
try(stabilize_int_xor_chr("1"))
#> Error in eval(expr, envir) : 
#>   `"1"` must match exactly one of the provided specifications, but matched
#> 2.
#> ℹ Matched specifications: "<fn>" (1) and "<fn>" (2)