Skip to contents

[Experimental]

assert_color() ensures that the provided color values are valid color names recognized by grDevices::colors() or valid hexadecimal color codes (#RGB or #RRGGBB).

Usage

assert_color(color, any_missing = FALSE, null_ok = FALSE)

Arguments

color

A character vector with color names or a hexadecimal color codes.

any_missing

(Optional) A logical flag indicating if missing values are allowed (Default: TRUE).

null_ok

(Optional) A logical flag indicating if NULL values are allowed (Default: FALSE).

Value

color (as invisible) if it passes the test; an error message otherwise.

Examples

assert_color("#FFF")
assert_color("#FF5733")
assert_color("#FF0000FF")
assert_color("blue")
assert_color("transparent")
assert_color(c("#FF5733", "blue", "transparent"))