<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 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