You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/validation/introduction.md
+22
Original file line number
Diff line number
Diff line change
@@ -132,6 +132,28 @@ class SongData extends Data
132
132
}
133
133
```
134
134
135
+
The above example will override the automatically inferred rules. If you want the manual rules to be merged with the automatically inferred rules, you can use the `MergeRules` attribute:
136
+
137
+
```php
138
+
#[MergeRules]
139
+
class SongData extends Data
140
+
{
141
+
public function __construct(
142
+
public string $title,
143
+
public string $artist,
144
+
) {
145
+
}
146
+
147
+
public static function rules(): array
148
+
{
149
+
return [
150
+
'title' => ['max:255'],
151
+
'artist' => ['max:255'],
152
+
];
153
+
}
154
+
}
155
+
```
156
+
135
157
You can read more about manual rules in its [dedicated chapter](/docs/laravel-data/v4/validation/manual-rules).
0 commit comments