Framework: Validator validated returns unvalidated data

Created on 25 Aug 2020  路  4Comments  路  Source: laravel/framework


  • Laravel Version: 7.18.0
  • PHP Version: 7.4

Description:

Form requests depend on the validator validated function to only return data that is validated and specified in the rules.

Steps To Reproduce:

Rules

return [

            'items' => [
                'array'
            ],

            'items.id' => [
                'string'
            ]
        ];

Input data:

{ "items" : { "id" : "a", "name" : "Twee" } }

Returned validated data:

Result of : $request->validated();

(
    [items] => Array
        (
            [id] => a
            [name] => Twee
        )

)

Expected:

(
    [items] => Array
        (
            [id] => a
        )

)

Adding an extra check in the Validator file to ensure no arrays are added back as a whole fixes the issue.

https://github.com/laravel/framework/pull/34005

Most helpful comment

Why is this even closed?

All 4 comments

Hi there,

Thanks for reporting but it looks like this is a question which can be asked on a support channel. Please only use this issue tracker for reporting bugs with the library itself. If you have a question on how to use functionality provided by this repo you can try one of the following channels:

However, this issue will not be locked and everyone is still free to discuss solutions to your problem!

Thanks.

@driesvints this is not a question? This is a bug?

Feel free to attempt that PR again but with a proper explanation and tests (see the PR template).

Why is this even closed?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JamborJan picture JamborJan  路  3Comments

digirew picture digirew  路  3Comments

kerbylav picture kerbylav  路  3Comments

shopblocks picture shopblocks  路  3Comments

gabriellimo picture gabriellimo  路  3Comments