Skip to content

Conversation

@weslenteche
Copy link
Contributor

Description:

When using the exclude, exclude_if, exclude_unless, exclude_with and exclude_without validations, the request data is not removed when retrieved in validated and validate method.

My system

Linux faf9a935b5e0 6.6.87.2-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC Thu Jun  5 18:30:46 UTC 2025 x86_64 Linux
PHP 8.3.14 (cli) (built: Nov 21 2024 08:44:42) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.14, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.14, Copyright (c), by Zend Technologies
hyperf/cache                       3.1.56  A cache component for hyperf.
hyperf/code-parser                 3.1.52  A code parser component for Hyperf.
hyperf/codec                       3.1.42  A codec component for Hyperf.
hyperf/collection                  3.1.52  Hyperf Collection package which come from illuminate/collections
hyperf/command                     3.1.56  Command for hyperf
hyperf/conditionable               3.1.42  Hyperf Macroable package which come from illuminate/conditionable
hyperf/config                      3.1.42  An independent component that provides configuration container.
hyperf/context                     3.1.42  A coroutine/application context library.
hyperf/contract                    3.1.42  The contracts of Hyperf.
hyperf/coordinator                 3.1.42  Hyperf Coordinator
hyperf/coroutine                   3.1.54  Hyperf Coroutine
hyperf/database                    3.1.56  A flexible database library.
hyperf/db-connection               3.1.44  A hyperf db connection handler for hyperf/database.
hyperf/devtool                     3.1.51  A Devtool for Hyperf.
hyperf/di                          3.1.53  A DI for Hyperf.
hyperf/dispatcher                  3.1.42  A HTTP Server for Hyperf.
hyperf/engine                      2.14.0  Coroutine engine provided by swoole.
hyperf/engine-contract             1.13.0  Contract for Coroutine Engine
hyperf/event                       3.1.42  an event manager that implements PSR-14.
hyperf/exception-handler           3.1.42  Exception handler for hyperf
hyperf/framework                   3.1.42  A coroutine framework that focuses on hyperspeed and flexible, specifically use for build microservices a...
hyperf/guzzle                      3.1.42  Swoole coroutine handler for guzzle
hyperf/http-message                3.1.48  microservice framework base on swoole
hyperf/http-server                 3.1.55  A HTTP Server for Hyperf.
hyperf/logger                      3.1.55  A logger component for hyperf.
hyperf/macroable                   3.1.42  Hyperf Macroable package which come from illuminate/macroable
hyperf/memory                      3.1.53  An independent component that use to operate and manage memory.
hyperf/model-listener              3.1.42  A model listener for Hyperf.
hyperf/pipeline                    3.1.42  Hyperf Macroable package which come from illuminate/pipeline
hyperf/pool                        3.1.42  An independent universal connection pool component.
hyperf/process                     3.1.48  A process component for hyperf.
hyperf/serializer                  3.1.42  A serializer component for Hyperf.
hyperf/server                      3.1.42  A base server library for Hyperf.
hyperf/stdlib                      3.1.42  A stdlib component for Hyperf.
hyperf/stringable                  3.1.55  Hyperf Stringable package which come from illuminate/support
hyperf/support                     3.1.51  A support component for Hyperf.
hyperf/tappable                    3.1.42  Hyperf Macroable package which come from illuminate/tappable
hyperf/testing                     3.1.55  Testing for hyperf
hyperf/translation                 3.1.42  An independent translation component, forked by illuminate/translation.
hyperf/utils                       3.1.42  A tools package that could help developer solved the problem quickly.
hyperf/validation                  3.1.53  hyperf validation
hyperf/watcher                     3.1.54  Hot reload watcher for Hyperf

swoole

Swoole => enabled
Author => Swoole Team <team@swoole.com>
Version => 6.0.1
Built => Feb 17 2025 02:52:16
coroutine => enabled with boost asm context
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
openssl => OpenSSL 3.1.8 11 Feb 2025
dtls => enabled
http2 => enabled
json => enabled
curl-native => enabled
curl-version => 8.12.1
c-ares => 1.27.0
zlib => 1.3.1
brotli => E16781312/D16781312
mutex_timedlock => enabled
pthread_barrier => enabled
coroutine_pgsql => enabled
coroutine_odbc => enabled
coroutine_sqlite => enabled

Directive => Local Value => Master Value
swoole.enable_library => On => On
swoole.enable_fiber_mock => Off => Off
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => Off => Off
swoole.unixsock_buffer_size => 8388608 => 8388608

Steps To Reproduce:

Request

class ValidateRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'foo' => ['exclude'],
        ];
    }
}

Controller

class ValidateController
{
    public function handle(ValidateRequest $request)
    {
        return [
            'message' => 'Validation passed',
            'all' => $request->all(),
            'validated' => $request->validated(),
        ];
    }
}

Output

{
    "message": "Validation passed",
    "all": {
        "foo": "foz"
    },
    "validated": {
        "foo": "foz"
    }
}

Expected

{
    "message": "Validation passed",
    "all": {
        "foo": "foz"
    },
    "validated": []
}

@limingxinleo limingxinleo changed the title fix: exclude validation Fixed bug that exclude cannot not work when using validation. Jun 30, 2025
@limingxinleo limingxinleo merged commit 87cdc7a into hyperf:master Jun 30, 2025
70 of 71 checks passed
@weslenteche weslenteche deleted the fix-exclude-validation branch July 5, 2025 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants