Nestable\Services\NestableService::isValid PHP Method

isValid() public method

Array validator.
public isValid ( string $type, $render = false ) : mixed
$type string
return mixed
    public function isValid($type, $render = false)
    {
        $original = $type;
        if (in_array($type, ['json', 'array'])) {
            $type = 'body';
        }
        $type = $type == 'multiple' ? 'dropdown' : $type;
        $fields = $this->config[$type];
        $valid = true;
        // mapping all data
        $this->data->map(function ($item) use($fields, &$valid, $type) {
            foreach ($fields as $field) {
                if ($valid && !empty($field)) {
                    $valid = isset($item[$field]);
                }
            }
        });
        // render data
        if ($valid && $render) {
            return call_user_func([$this, 'renderAs' . ucfirst($original)]);
        }
        return $valid;
    }