Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[10.x] Add list rule #50437

Closed
wants to merge 3 commits into from
Closed

Conversation

medilies
Copy link
Contributor

@medilies medilies commented Mar 9, 2024

When I want my API to receive a JSON array, the current array rule allows both JSON arrays and JSON objects. With this list rule, I can be sure I will receive [1, 2, 3] instead of {"a": 1, "b": 2, "c": 3}.

@medilies medilies changed the title [10.x] add list rule [10.x] Add list rule Mar 9, 2024
@medilies
Copy link
Contributor Author

medilies commented Mar 9, 2024

I forgot to this 'list' => 'The :attribute field must be a list.', to src\Illuminate\Translation\lang\en\validation.php and I'm a afraid a new commit from me will rerun the actions.

@fragkp
Copy link
Contributor

fragkp commented Mar 9, 2024

I forgot to this 'list' => 'The :attribute field must be a list.', to src\Illuminate\Translation\lang\en\validation.php and I'm a afraid a new commit from me will rerun the actions.

It will trigger a rerun, but thats totally fine.

@diegogit03
Copy link

Maybe this rule can receive a datatype something like list:number or list:string

@medilies
Copy link
Contributor Author

That's a good point @diegogit03 but I didn't try to handle that in this rule because the developer can use something like ['field' => 'list', 'field.*' => 'number'].

@taylorotwell
Copy link
Member

Can you send to 11.x branch?

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