validate container existence
@param  {Object} container instance.attrs.container - instance container json
@return {Error}  err       returns err only if container does not exist
505815
function validateContainer (container) {
  var err;
  if (!container || container.error) {
    err = Boom.create(504, 'instance is down (no container)', container.error);
  }
  else if (container.inspect.error) {
    err = Boom.create(503, 'instance inspect failed (try again)', container.inspect.error);
  }

  return err;
}
640622
function(datum) {
    return Promise.retry(function() {
      if (getId(datum)) {
          // Get list of containers.
        return list(null)
        .then(function(containers) {
          // Build set of all valid container ids.
          var idSet =
            _(containers)
            .chain()
            .map(function(container) {
              return [container.id, container.name];
            })
            .flatten()
            .uniq()
            .object()
            .value();
          // Search set of valid containers for data.
          return _.has(idSet, getId(datum));
        });
      }
      else if (datum.compose) {
        return compose.getId(datum.compose, datum.project, datum.opts)
        .then(function(id) {
          return !_.isEmpty(id);
        });
      }
    });
  }
229489
def validate(cls):
        
        if cls.get_dict():
            cls.show_error(False)
            return True

        cls.show_error(True)
        return False
1165916
function (elementId, containerId) {
            var container = this.$containers[containerId];
            if (!container) {
                // TODO: remove this shit
                container = this.createContainer({'class': containerId + "-container"});
                this.$containers[containerId] = container;
                this.addChild(container);
                if (this.$containerOrder[containerId]) {
                    container.setChildIndex(this.$containerOrder[containerId]);
                }
            }

            var element = this.$elements[containerId + "_" + elementId];
            if (!element) {
                element = this.createContainer({});
                container.addChild(element);
            }

            return element.$el;
        }
1016543
function(attr, value) {
          var self = this,
              result = {},
              error;

          if(_.isObject(attr)){
            _.each(attr, function(value, key) {
              error = self.preValidate(key, value);
              if(error){
                result[key] = error;
              }
            });

            return _.isEmpty(result) ? undefined : result;
          }
          else {
            return validateAttr(this, attr, value, _.extend({}, this.attributes));
          }
        }
829340
function(cid) {

    // Find a generic container.
    return findGenericContainer(cid)
    .then(function(container) {
      if (container) {
        // Map container id to a docker container.
        return dockerInstance().call('getContainer', container.id);
      } else {
        return undefined;
      }
    });

  }
1374253
function() {
            var container;
            //first, try get it by `containerDataName`
            if(this.containerDataName) {
                if(container = this.$element.data(this.containerDataName)) {
                    return container;
                }
            }
            //second, try `containerName`
            container = this.$element.data(this.containerName);
            return container;
        }
97256
function() {
            this.containerOptions = {};
            this.formOptions = {};
            
            if(!$.fn[this.containerName]) {
                throw new Error(this.containerName + ' not found. Have you included corresponding js file?');   
            }
            
            var cDef = $.fn[this.containerName].defaults;
            //keys defined in container defaults go to container, others go to form
            for(var k in this.options) {
              if(k in cDef) {
                 this.containerOptions[k] = this.options[k];
              } else {
                 this.formOptions[k] = this.options[k];
              } 
            }
        }
326767
def is_alive(self, container: Container) -> bool:
        
        uid = container.uid
        r = self.__api.get('containers/{}/alive'.format(uid))

        if r.status_code == 200:
            return r.json()

        if r.status_code == 404:
            raise KeyError("no container found with given UID: {}".format(uid))

        self.__api.handle_erroneous_response(r)
550017
def is_valid(container, path):
    
    try:
        tmp_hash_path = container.filename + ".hash"
        with open(tmp_hash_path, 'r') as tmp_file:
            tmp_hash = tmp_file.readline()
    except IOError:
        LOG.info("No .hash-file in the tmp-directory.")

    container_hash_path = local.path(path) / "gentoo.tar.bz2.hash"
    if container_hash_path.exists():
        with open(container_hash_path, 'r') as hash_file:
            container_hash = hash_file.readline()
            return container_hash == tmp_hash
    return False
1121716
function validateEnvironment(environment, source) {

		// not having an environment is ok
		if (!environment) {
			return;
		}

		if (Array.isArray(environment)) {
			throw new Error("Environment must not be an array");
		}

		if (typeof environment === "object") {
			Object.keys(environment).forEach(function(env) {
				if (!Environments.env) {
					var message = [
						source, ":\n",
						"\tEnvironment key \"", env, "\" is unknown\n"
					];

					throw new Error(message.join(""));
				}
			});
		} else {
			throw new Error("Environment must be an object");
		}
	}
1374183
def _check_required(self, value):
        '''
        
        '''
        if value is None and self._required:
            err_msg = self._errors['required'].format(self.__class__.__name__, self.name)
            if self.container_model:
                err_msg += self._errors['required_extra'].format(self.container_model.__name__)
            raise ValueError(err_msg)
1359736
def first_container_with_errors(self, errors):
        
        for tab in self.fields:
            errors_here = any(error in tab for error in errors)
            if errors_here:
                return tab
        return None
329406
function() {
    var args = this.store.utils.args(arguments)
    if (args.length > 1) {
      return this.validateFieldsHelper(args, this.validatesPresenceOf)
    }

    var field = args[0]

    if (Array.isArray(field)) {
      return this.validateFieldsHelper(field, [], this.validatesPresenceOf)
    }

    return this.validates(field, function() {
      var valid = this[field] != null
      if (!valid) this.errors.add(field, 'should be present')
      return valid
    })
  }
137879
function checkError(method,res) {
    var descriptions = {
        200:	'Success',
        201:	'Success - new resource created (POST)',
        204:	'Success - no content to return (DELETE)',
        400:	'Bad Request - request couldn\'t be parsed',
        401:	'Unauthorized - OAuth must be provided',
        403:	'Forbidden - invalid API key or unapproved app',
        404:	'Not Found - method exists, but no record found',
        405:	'Method Not Found - method doesn\'t exist',
        409:	'Conflict - resource already created',
        412:	'Precondition Failed - use application/json content type',
        422:	'Unprocessable Entity - validation errors',
        429:	'Rate Limit Exceeded',
        500:	'Server Error',
        503:	'Service Unavailable - server overloaded',
        520:	'Service Unavailable - Cloudflare error',
        521:	'Service Unavailable - Cloudflare error',
        522:	'Service Unavailable - Cloudflare error '  
    }
    if (CODEOK[(method).toUpperCase()].indexOf(res.statusCode)>=0) {
        return null;
    }
    var e = new Error('trakter: ' + descriptions[res.statusCode]);
    e.name = 'TrakterBadResponse';
    e.code = res.statusCode
    return e;
}
325088
public function containerExists($container = '')
    {
        $this->checkConnection();

        try {
            /** @var Container $container */
            $container = $this->blobConn->getContainer($container);

            return !empty($container);
        } catch (\Exception $ex) {
            if ($ex instanceof ClientErrorResponseException) {
                if ($ex->getCode() === 404 || str_contains($ex->getMessage(), '404')) {
                    return false;
                }
            }
            static::handleGuzzleException($ex);
            throw new DfException('Failed to list containers: ' . $ex->getMessage());
        }
    }
1009434
function(resolve) {
    var self = this
    return this.validate()
      .then(function() {
        return true
      })
      .catch(function(error) {
        if (error instanceof self.store.ValidationError) return false
        throw error
      })
      .then(resolve)
  }