def optional_string(value):
    """Raise an exception if a value isn't a string, or None."""
    if not isinstance(value, (str, type(None))):
        raise ValueError('Expected a string value or None, received %s.' %
            value)
    return value
