def _assert_matches_re(self, field, expected_patterns):
value = getattr(self, field)<EOL>for pattern in expected_patterns:<EOL><INDENT>try:<EOL><INDENT>if pattern.match(value):<EOL><INDENT>return<EOL><DEDENT><DEDENT>except AttributeError:<EOL><INDENT>if re.match(pattern, value):<EOL><INDENT>return<EOL><DEDENT><DEDENT><DEDENT>raise ValueError("<STR_LIT>"<EOL>% (self.__class__.__name__, field, value, expected_patterns))<EOL>
The list of patterns can contain either strings or compiled regular
expressions.