Skip to content

Conversation

@SocolaDaiCa
Copy link

@SocolaDaiCa SocolaDaiCa commented Aug 27, 2023

protected $except = [
        'current_password',
        'password',
        'password_confirmation',
];

sometimes I send form request as

Create many users

[
	'users' => [
		[
			'email' => '',
			'password' => '',
		],
		[
			'email' => '',
			'password' => '',
		],
	],
],

or create company with a new admin

[
	'name' => '',
	'location' => '',
	'admin' => [
		'email' => '',
		'password' => '',
	],
],

I need define except like admin.password, users.0.password, users.1.password, .... , users.n.password. I cant define all of it

I think TrimStrings should support nested attribute, when define password it match *.password, *.*.password ... etc

my english is not good, sorry if i write curtly or hard to understand

@driesvints
Copy link
Member

Please add a thorough explanation to this PR.

@driesvints driesvints marked this pull request as draft August 28, 2023 06:47
@driesvints driesvints changed the title feat(TrimStrings): support nested attribute [11.x] TrimStrings: support nested attribute Aug 28, 2023
@SocolaDaiCa
Copy link
Author

Hi @driesvints , I had update explanation to this PR, please help me review It

@driesvints driesvints marked this pull request as ready for review August 28, 2023 07:36
@ntiyiso-rikhotso
Copy link

I think @SocolaDaiCa is trying to use the dot notation to exclude some array keys from being trimmed

e.g
Given the payload:

[
	'users' => [
		[
			'email' => '[email protected]',
			'password' => 'password#',
		],
		[
			'email' => '[email protected]',
			'password' => '/password',
		],
	],
],

He wants the possibility to exclude a password from being trimmed by adding it like

protected $except = [
        'users.*.password'
];

Apologies if I did not understand your pull request @SocolaDaiCa

@taylorotwell
Copy link
Member

Thanks for your pull request to Laravel!

Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include.

If possible, please consider releasing your code as a package so that the community can still take advantage of your contributions!

If you feel absolutely certain that this code corrects a bug in the framework, please "@" mention me in a follow-up comment with further explanation so that GitHub will send me a notification of your response.

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