goalie.is_hex_color

goalie.is_hex_color(x: object) bool

Check whether the input is a hexadecimal color code.

Matches standard 6-digit hex colors with an optional 2-digit alpha suffix (e.g. #FF0000 or #FF0000FF).

Parameters:

x (object) – Value to check.

Returns:

True if x is a hex color code.

Return type:

bool

Examples

>>> is_hex_color("#FF0000")
True
>>> is_hex_color("#FF0000FF")
True
>>> is_hex_color("red")
False