Checks properties values

@throws \Exception   if some property contains incorrect value.
329460
protected function checkProperties()
    {
        if (!$this->getRequestReader() instanceof RequestReader) {
            $this->throwException('Class for RequestReader should be inherit from "%baseClass%" ' .
                '(see SmartLoad option/property "%option%")', array(
                '%baseClass%' => RequestReader::className(),
                '%option%'    => 'requestReaderClassName'
            ));
        }

        $supportedHashAlgorithms = hash_algos();
        if (is_string($this->hashMethod) && !in_array($this->hashMethod, $supportedHashAlgorithms)) {
            $this->throwException('Incorrect hashing method (see SmartLoad option/property "%option%"). ' .
                'Supported hash algorithms: %hashAlgorithms% ', array(
                '%hashAlgorithms%' => join(', ', $supportedHashAlgorithms),
                '%option%'         => 'hashMethod'
            ));
        }

        // todo check other properties
    }
894722
private function checkTypes(string $property, $value)
    {
        $integrityConstraints = $this->getIntegritySpecification($property);

        $actualValueType = gettype($value);

        if ($actualValueType == 'double') {
            $actualValueType = is_int($value) ? 'integer' : 'number';
        } else {
            if ($actualValueType == 'NULL') {
                $actualValueType = 'null';
            }
        }

        if (count($integrityConstraints)) {
            // object check
            if ($actualValueType == 'object') {
                if (!in_array(get_class($value), $integrityConstraints)) {
                    throw new PropertyValueNotValidException("Type error: Property [$property] accepts only [".implode(',', $integrityConstraints).'], but given value is instance of : [' . get_class($value).']');
                }
            } else {
                // primitive type value
                $isValidType = false;
                foreach ($integrityConstraints as $type) {
                    if ($type === 'object' && is_object($value)) {
                        $isValidType = true;
                        break;
                    } elseif ($type == 'array' && is_array($value)) {
                        $isValidType = true;
                        break;
                    } elseif ($type == 'string' && is_string($value)) {
                        $isValidType = true;
                        break;
                    } elseif ($type == 'number' && is_numeric($value)) {
                        $isValidType = true;
                        break;
                    } elseif (($type == 'integer' || $type == 'int') && is_int($value)) {
                        $isValidType = true;
                        break;
                    } elseif (($type == 'boolean' || $type == 'bool') && is_bool($value)) {
                        $isValidType = true;
                        break;
                    } elseif ($type == 'null' && $value === null) {
                        $isValidType = true;
                        break;
                    }
                }
                if (!$isValidType) {
                    throw new PropertyValueNotValidException("Type error: Property [$property] accepts only [".implode(',', $integrityConstraints)."], but given value is: [$actualValueType]");
                }
            }
        }

        return true;
    }
755638
public function validate($check_children = true)
    {
        //validate
        foreach (static::getProperties() as $property => $meta) {
            $mandatory = $meta[self::KEY_MANDATORY];

            //If it's got a GUID, it's already going to be valid almost all cases
            if (! $this->hasGUID() && $mandatory) {
                if (! isset($this->_data[$property]) || empty($this->_data[$property])) {
                    throw new Exception(
                        sprintf(
                            '%s::$%s is mandatory and is either missing or empty.',
                            get_class($this),
                            $property
                        )
                    );
                }

                if ($check_children) {
                    if ($this->_data[$property] instanceof self) {
                        //Keep IDEs happy
                        /** @var self $obj */
                        $obj = $this->_data[$property];
                        $obj->validate();
                    } elseif ($this->_data[$property] instanceof Collection) {
                        foreach ($this->_data[$property] as $element) {
                            if ($element instanceof self) {
                                $element->validate();
                            }
                        }
                    }
                }
            }
        }

        return true;
    }
1006486
public function listInvalidProperties()
    {
        $invalid_properties = [];

        if ($this->container['region'] === null) {
            $invalid_properties[] = "'region' can't be null";
        }
        $allowed_values = $this->getRegionAllowableValues();
        if (!in_array($this->container['region'], $allowed_values)) {
            $invalid_properties[] = sprintf(
                "invalid value for 'region', must be one of '%s'",
                implode("', '", $allowed_values)
            );
        }

        if ($this->container['machineType'] === null) {
            $invalid_properties[] = "'machineType' can't be null";
        }
        $allowed_values = $this->getMachineTypeAllowableValues();
        if (!in_array($this->container['machineType'], $allowed_values)) {
            $invalid_properties[] = sprintf(
                "invalid value for 'machineType', must be one of '%s'",
                implode("', '", $allowed_values)
            );
        }

        if ($this->container['size'] === null) {
            $invalid_properties[] = "'size' can't be null";
        }
        if ($this->container['billingType'] === null) {
            $invalid_properties[] = "'billingType' can't be null";
        }
        $allowed_values = $this->getBillingTypeAllowableValues();
        if (!in_array($this->container['billingType'], $allowed_values)) {
            $invalid_properties[] = sprintf(
                "invalid value for 'billingType', must be one of '%s'",
                implode("', '", $allowed_values)
            );
        }

        if ($this->container['machineName'] === null) {
            $invalid_properties[] = "'machineName' can't be null";
        }
        if ($this->container['templateId'] === null) {
            $invalid_properties[] = "'templateId' can't be null";
        }
        return $invalid_properties;
    }
59042
function( value, properties ) {
			var errors = [];

			// Convert the properties to an array:
			properties = properties.split( ',' );

			// Check for each property:
			for ( var i = 0; i < properties.length; i++ ) {
				if ( !value.hasOwnProperty( properties[ i ] ) ) {
					errors.push({
						"rule": "hasProperties",
						"message": "ERROR:value does not have the following property: " + properties[ i ]
					});
				}
			} // end FOR i

			return errors;
		}
743488
private void checkForOverride(Properties properties, String name, String attr, String value) {
		String propertyValue = properties.getProperty(attr);
		if (propertyValue != null && !propertyValue.equals(value)) {
			LOG.warn(name + ":an attempt to override final parameter: " + attr
					+ ";  Ignoring.");
		}
	}
237928
public function hasValues()
    {
        $keys = array_values($this->data[0]);
        foreach ($this->data[1] as $key) {
            $this->failIf((!in_array($key, $keys)));
        }
    }
224630
public function isValid($value)
    {
        $valueString = (string) $value;

        $this->_setValue($valueString);

        $status = @preg_match($this->_pattern, $valueString);
        if (false === $status) {
            /**
             * @see Zend_Validate_Exception
             */
            include_once 'Zend/Validate/Exception.php';
            throw new Zend_Validate_Exception("Internal error matching pattern '$this->_pattern' against value '$valueString'");
        }
        if (!$status) {
            $this->_error();
            return false;
        }
        return true;
    }
497392
public function checkPaths()
    {
        $path = Yii::getAlias($this->templatePath, false);

        if (!$path || !is_dir($path)) {
            throw new Exception("The template path \"{$this->templatePath}\" does not exist");
        }
    }
751137
public function checkValidProperties()
    {
        if (!$this->controller && !$this->action && !$this->callable) {
            throw new \Parable\Routing\Exception('Either a controller/action combination or callable is required.');
        }
        if (empty($this->methods)) {
            throw new \Parable\Routing\Exception('Methods are required and must be passed as an array.');
        }
        return $this;
    }
381302
protected function validateConf()
    {
        foreach ($this->getRequiredConfParams() as $name => $type) {
            if (!isset($this->params[$name]) || gettype($this->params[$name]) !== $type) {
                throw new Exception("Parameter '{$name}' missing or not of type '{$type}' (adapter '{$this->name}')");
            }
            if (substr($name, -5) == '_path') {
                $path = $this->getConfParam($name);
                if (!is_file($path)) {
                    throw new Exception("File not found: $path");
                }
            }
        }
    }
1325449
public function isValid()
    {
        $value = $this->field->getValue();

        if (is_array($value) || is_object($value)) {
            throw new \Exception("This validator only works on scalar types!");
        }

        // required but not given
        if ($this->required && $value == null) {
            return false;
        } // if the field is not required and the value is empty, then it's also valid
        elseif (!$this->required && $value == "") {
            return true;
        }

        // now, walk all chars and check if they are in the blacklist
        for ($i = 0; $i < strlen($value); $i++) {
            if (in_array(strval($value[$i]), $this->blacklist, true)) {
                // not in the blacklist!
                return false;
            }
        }

        // if here, everything is ok!
        return true;
    }
357302
public function isValid()
    {
        $value = $this->field->getValue();

        if (is_array($value) || is_object($value)) {
            throw new \Exception("This validator only works on scalar types!");
        }

        // required but not given
        if ($this->required && $value == null) {
            return false;
        } // if the field is not required and the value is empty, then it's also valid
        elseif (!$this->required && $value == "") {
            return true;
        }

        $match = preg_match($this->regex, $value);

        return $this->not ? !$match : $match;
    }
761857
public function check()
    {
        $returnValue = null;

        
        $validity = null;
        $name = $this->getName();
        if (($value = ini_get($name)) !== false){
            // The ini value exists for this name.
            if ((($value == '') ? '0' : $value) == $this->getExpectedValue()){
                $validity = common_configuration_Report::VALID;
                $message = "PHP Configuration Option '${name}' = '${value}' has an expected value.";
            }
            else {
                $validity = common_configuration_Report::INVALID;
                $message = "PHP Configuration Option '${name}' = '${value}' has an unexpected value.";
            }
        }
        else {
            // Unknown ini value name.
            $validity = common_configuration_Report::UNKNOWN;
            $message = "PHP Configuration Option '${name}' is unknown.";
        }

        $returnValue = new common_configuration_Report($validity, $message, $this);
        

        return $returnValue;
    }
594546
public function listInvalidProperties()
    {
        $invalid_properties = [];
        if ($this->container['characterId'] === null) {
            $invalid_properties[] = "'characterId' can't be null";
        }
        if ($this->container['joinTime'] === null) {
            $invalid_properties[] = "'joinTime' can't be null";
        }
        if ($this->container['role'] === null) {
            $invalid_properties[] = "'role' can't be null";
        }
        $allowed_values = ["fleet_commander", "wing_commander", "squad_commander", "squad_member"];
        if (!in_array($this->container['role'], $allowed_values)) {
            $invalid_properties[] = "invalid value for 'role', must be one of #{allowed_values}.";
        }

        if ($this->container['roleName'] === null) {
            $invalid_properties[] = "'roleName' can't be null";
        }
        if ($this->container['shipTypeId'] === null) {
            $invalid_properties[] = "'shipTypeId' can't be null";
        }
        if ($this->container['solarSystemId'] === null) {
            $invalid_properties[] = "'solarSystemId' can't be null";
        }
        if ($this->container['squadId'] === null) {
            $invalid_properties[] = "'squadId' can't be null";
        }
        if ($this->container['takesFleetWarp'] === null) {
            $invalid_properties[] = "'takesFleetWarp' can't be null";
        }
        if ($this->container['wingId'] === null) {
            $invalid_properties[] = "'wingId' can't be null";
        }
        return $invalid_properties;
    }
1264200
public function check()
    {
        $returnValue = null;

        
        $name = $this->getName();
        $min = $this->getMin();
        $max = $this->getMax();
        $validity = null;
        $message = null;
        
        if (extension_loaded($name)){
            $current = $this->getValue();
            
            if (!empty($min) && !empty($max)){
                // Both min and max are specified.
                if (version_compare($current, $min, '>=') && version_compare($current, $max, '<=')){
                    $validity = common_configuration_Report::VALID;
                    $message = "PHP Extension '${name}' version (${current}) is between ${min} and ${max}.";
                }
                else{
                    $validity = common_configuration_Report::INVALID;
                    $message = "PHP Extension '${name}' version (${current}) is not between ${min} and ${max}.";
                }
            }
            else if (!empty($min) && empty($max)){
                // Only min is specified.
                if (version_compare($current, $min, '>=')){
                    $validity = common_configuration_Report::VALID;
                    $message = "PHP Extension '${name}' version (${current}) is greater or equal to ${min}.";
                }
                else{
                    $validity = common_configuration_Report::INVALID;
                    $message = "PHP Extension '${name}' version (${current}) is lesser than ${min}.";
                }
            }
            else if (empty($min) && !empty($max)){
                // Only max is specified.
                if (version_compare($current, $max, '<=')){
                    $validity = common_configuration_Report::VALID;
                    $message = "PHP Extension '${name}' version (${current}) is lesser or equal to ${max}.";
                }
                else{
                    $validity = common_configuration_Report::INVALID;
                    $message = "PHP Extension '${name}' version (${current}) is greater than ${max}.";
                }
            }
            else{
                // No min and max are provided, we just check the
                // existence of the extension (already done).
                $validity = common_configuration_Report::VALID;
                $message = "PHP Extension '${name}' is loaded.";
            }
        }
        else{
            $validity = common_configuration_Report::UNKNOWN;
            $message = "PHP Extension '${name}' could not be found.";
        }

        $returnValue = new common_configuration_Report($validity, $message, $this);
        

        return $returnValue;
    }
1075825
public function checkValuesUponSave()
    {
        foreach ($this->getJsonColumns() as $column_name) {
            if (isset($this->attributes[$column_name]) && !is_string($this->attributes[$column_name])) {
                if (is_array($this->attributes[$column_name])) {
                    $this->attributes[$column_name] = json_encode($this->attributes[$column_name]);
                } elseif (is_object($this->attributes[$column_name])) {
                    $this->attributes[$column_name] = (string) $this->attributes[$column_name];
                }
            }
        }
    }