'Validates that the string compiles as a regular expression.
Because the regular expression might have been expressed as a multiline
string, this function also strips newlines out of value.
Args:
value: String to compile as a regular expression.
key: Name of the field being validated.
Raises:
ValueError when value does not compile as a regular expression.  TypeError
when value does not match provided string type.'

def Validate(self, value, key):

    if isinstance(value, _RegexStrValue):
        return value
    value = _RegexStrValue(self, value, key)
    value.Validate()
    return value
