recursively validates a value

@access protected
@param string $key
@param mixed $val
@return bool
770993
protected function _validate($key, $val)
    {
        // try each rule function
        foreach ($this->rules as $rule => $is_true) {
            if ($is_true) {
                $function = $this->functions[$rule];
                $args = $this->arguments[$rule]; // Arguments of rule

                $valid = true;
                if(is_array($val)) {
                    foreach($val as $v) {
                        $valid = $valid && (empty($args)) ? $function($v) : $function($v, $args);
                    }
                } else {
                    $valid = (empty($args)) ? $function($val) : $function($val, $args);
                }

                if ($valid === FALSE) {
                    $this->registerError($rule, $key);

                    $this->rules = array();  // reset rules
                    $this->filters = array();
                    return FALSE;
                }
            }
        }

        $this->validData[$key] = $val;
        return TRUE;
    }
227411
public function assignByRef($key, &$val = null)
    {
        if (is_array($key)) {
            foreach ($key as $k => &$v) {
                $this->args[$k] = $v;
            }
        } else {
            $this->args[$key] = $val;
        }
        return $this;
    }
226078
public function addElement($key, $val)
    {
        $this->myData = array_merge($this->myData, array((String)$key => $val));
    }
1040449
public function set($key, $val)
    {
        if (!$this->locked) {
            $this->options[$key] = $val;
        }

        return $this;
    }
1181340
public function decrement($key, $val = 1)
    {
        return $this->hash($key)->decrBy($key, abs(intval($val)));
    }
402428
public function set(string $key, $val)
    {
        // set the variable
        if (empty($key)) {
            return $this;
        }

        $node = $this->mainNode->getLastByKey($key);

        if (!$node || !$node->getParent()) {
            $newNode = new Node($this->mainNode, $key, $val);
            $this->mainNode->addChild($newNode);
        } else {
            $newNode = new Node($node->getParent(), $key, $val);
            $node->getParent()->addChild($newNode);
        }

        $this->lastNewNode = $newNode;

        return $this;

    }
1007012
function set($key,$val):bool
    {
        if($this->isStart){
            $this->data[$key] = $val;
            return true;
        }else{
            trigger_error('session is close now,please start session');
            return false;
        }
    }
1053064
public function index($key, $val)
    {
        $db = $this->load();
        foreach ($db as $index => $row) {
            if ($row[$key] === $val) {
                return $index;
                break;
            }
        }
        return -1;
    }
395042
protected function label($key, $val)
    {
        $extra = [
            'type' => strtolower(__FUNCTION__),
        ];

        return $this->composeElement($key, $val, $extra);
    }
769425
protected function button($key, $val)
    {
        $extra = [
            'type' => strtolower(__FUNCTION__),
        ];

        return $this->composeElement($key, $val, $extra);
    }
49673
public static function set($key, $val)
    {
        if( ! is_string($key)) {
            return;
        }
        $key = strtoupper($key);
        if ( ! strpos($key, '.')) {
            self::$config[$key] = $val;
        } else {
            // 试图获取二维数组值
            $d = explode('.', $key);
            $d1 = array_shift($d);
            $d2 = implode('.', $d);

            if (is_array(self::$config[$d1]) || ! isset(self::$config[$d1])) {
                self::$config[$d1][$d2] = $val;
            }
        }
    }
197087
public static function isList($val): bool
    {
        if (!\is_array($val) || !isset($val[0])) {
            return false;
        }

        /** @var array $val */
        $keys = \array_keys($val);

        return \array_keys($keys) === $keys;
    }
187358
public final function set ($key, $val)
    {
        if (in_array($key, $this->getColumn())) {
            $this->record->{$key} = $val;
            return true;
        }

        return false;
    }
521478
public function increment($key, $val = 1)
    {
        return apc_inc($this->conf['prefix'] . $key, abs(intval($val)));
    }
853212
protected function _setRaw($key, $val) {
        $set = false;
        if ($val === null) {
            $this->_fields[$key] = null;
            $set = true;
        } else {
            $phptype = $this->_getPHPType($key);
            $dbtype = $this->_getDataType($key);
            switch ($phptype) {
                case 'int':
                case 'integer':
                case 'boolean':
                    $this->_fields[$key] = (integer) $val;
                    $set = true;
                    break;
                case 'float':
                    $this->_fields[$key] = (float) $val;
                    $set = true;
                    break;
                case 'array':
                    if (is_array($val)) {
                        $this->_fields[$key]= serialize($val);
                        $set = true;
                    } elseif (is_string($val)) {
                        $this->_fields[$key]= $val;
                        $set = true;
                    } elseif (is_object($val) && $val instanceof xPDOObject) {
                        $this->_fields[$key]= serialize($val->toArray());
                        $set = true;
                    }
                    break;
                case 'json':
                    if (!is_string($val)) {
                        $v = $val;
                        if (is_array($v)) {
                            $this->_fields[$key] = $this->xpdo->toJSON($v);
                            $set = true;
                        } elseif (is_object($v) && $v instanceof xPDOObject) {
                            $this->_fields[$key] = $this->xpdo->toJSON($v->toArray());
                            $set = true;
                        }
                    } else {
                        $this->_fields[$key]= $val;
                        $set = true;
                    }
                    break;
                case 'date':
                case 'datetime':
                case 'timestamp':
                    if (preg_match('/int/i', $dbtype)) {
                        $this->_fields[$key] = (integer) $val;
                        $set = true;
                        break;
                    }
                default:
                    $this->_fields[$key] = $val;
                    $set = true;
            }
        }
        if ($set) $this->setDirty($key);
        return $set;
    }
1366045
protected function filterAttachmentOption($val, $key)
    {
        if ($val === null) {
            return false;
        }

        switch ($key) {
            case 'isActive':
                return is_bool($val);

            case 'before':
            case 'after':
                return is_callable($val);
        }

        return true;
    }
200631
protected function validate_point($val) {
        if (empty($val)) {
            return false;
        }
        $maxgrade = (int)get_config('core', 'gradepointmax');
        $isintlike = ((string)(int)$val === $val) ? true : false;
        return ($isintlike === true && $val > 0 && $val <= $maxgrade) ? true : false;
    }