public function filter($var, $filters, $type = null)
    {
        if (!is_array($filters)) {
            $filters = $filters ? explode('|', $filters) : [];
        }

        $value = &$this->data[$var] ?? null;
        if ($value === null) {
            return null;
        }
        foreach ($filters as $key => $filter) {
            $params = explode(':', $filter);
            $filter = is_string($key) ? $key : array_shift($params);
            $filter = $this->filters[$filter] ?? function (&$data) use ($filter, $params) {
                $data = $filter($data, ...$params);
            };

            $errors = $filter($value, ...$params);
            if ($errors) {
                $this->errors[$var] = $errors;
                break;
            }
            if ($value === null) {
                return null;
            }
        }

        if ($type) {
            settype($value, $type);
        }

        return $value;
    }