'Does validation of a string against a regular expression.
Args:
value: String to match against regular expression.
key: Name of the field being validated.
Raises:
ValidationError: when value does not match regular expression or
when value does not match provided string type.'

def Validate(self, value, key):

    if issubclass(self.expected_type, str):
        cast_value = TYPE_STR(value)
    else:
        cast_value = TYPE_UNICODE(value)
    if (self.re.match(cast_value) is None):
        raise ValidationError(("Value    '%s'    for    %s    does    not    match    expression    '%s'" % (value, key, self.re.pattern)))
    return cast_value
