Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2513,6 +2513,19 @@ $validator = Validator::make($request->all(), [
]);
```

You may also use the `*` as a key of a sub-array. For example, if your users have an `email` and a `last_name` in a given sub-array input field, you may do the following:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "sub-array" actually hyphenated?

Copy link
Author

@fgaroby fgaroby Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same word is already used in helpers.


```php
$validator = Validator::make($request->all(), [
'users' => [
'*' => [
'email' => 'email|unique:users',
'first_name' => 'required_with:users.*.last_name',
],
],
]);
```

Likewise, you may use the `*` character when specifying [custom validation messages in your language files](#custom-messages-for-specific-attributes), making it a breeze to use a single validation message for array-based fields:

```php
Expand Down