def validate_exists(args, key, default=None):
    if key in args:
        if len(args[key]) == 0:
            raise ArgumentError(_('Argument %(key)s value %(value)s is too '
                                  'short.') %
                                {'key': key,
                                 'value': args[key]})
        if not ARGUMENT_PATTERN.match(args[key]):
            raise ArgumentError(_('Argument %(key)s value %(value)s contains '
                                  'invalid characters.') %
                                  {'key': key,
                                   'value': args[key]})
        if args[key][0] == '-':
            raise ArgumentError(_('Argument %(key)s value %(value)s starts '
                                  'with a hyphen.') %
                                {'key': key,
                                 'value': args[key]})
        return args[key]
    elif default is not None:
        return default
    else:
        raise ArgumentError(_('Argument %s is required.') % key)
Validates that a string argument to a RPC method call is given, and
dataset/ETHPy150Open nii-cloud/dodai-compute/plugins/xenserver/xenapi/etc/xapi.d/plugins/pluginlib_nova.py/validate_exists