public function getValidInput($clean = false)
    {
        $input = array_dot($this->all());
        $rules = array_keys($this->rules());

        $keys = collect($rules)->map(function (string $rule) use ($input) {
            // Transform each rule to a regex string while supporting
            // the wildcard (*) character to include sequential arrays too.
            $regex = '/^' . str_replace(['.', '*'], ['\.', '(.*)'], $rule) . '$/';

            // Match the regex string against our input fields
            return preg_grep($regex, array_keys($input));
        });

        // Match the input attributes against the existing rules
        $input = array_only($input, $keys->flatten()->toArray());

        // Reverse dot flattening to match original input
        $expanded = [];

        foreach ($input as $key => $value) {
            array_set($expanded, $key, $value);
        }

        if ($clean) {
            $expanded = $this->sanitizeInput($expanded);
        }

        return $expanded;
    }