def _validate_color(self, color):
        """Validates color, raising error if invalid."""

        three_digit_pattern = compile("^[a-f0-9]{3}$")
        six_digit_pattern = compile("^[a-f0-9]{6}$")

        if not match(three_digit_pattern, color)\
            and not match(six_digit_pattern, color):
                raise InvalidColorError(
                    "{} is not a valid color".format(color)
                )

        return color
Validates color, raising error if invalid.