Enables ensuring that one of multiple optional fields is set

def contains_one_of(*fields):
    """Enables ensuring that one of multiple optional fields is set"""
    message = 'Must contain any one of the following fields: {0}'.format(', '.join(fields))

    def check_contains(endpoint_fields):
        for field in fields:
            if field in endpoint_fields:
                return

        errors = {}
        for field in fields:
            errors[field] = 'one of these must have a value'
        return errors
    check_contains.__doc__ = message
    return check_contains