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: 3.1/imports/validation.md
+25
Original file line number
Diff line number
Diff line change
@@ -363,6 +363,31 @@ class UsersImport implements ToCollection
363
363
}
364
364
```
365
365
366
+
## Configuring the validator
367
+
If you want to add conditional validation or complex validation that cannot be expressed through rules you can configure the validator similar to how you would do this with a [Form request](https://laravel.com/docs/master/validation#form-request-validation)
368
+
369
+
:::tip Manual validation
370
+
You can use `$validator->getData()` to get access to the data under validation
371
+
:::
372
+
373
+
```php
374
+
class UsersImport implements WithValidation
375
+
{
376
+
public function withValidator($validator)
377
+
{
378
+
$validator->after(function ($validator) {
379
+
if ($this->somethingElseIsInvalid()) {
380
+
$validator->errors()->add('field', 'Something is wrong with this field!');
0 commit comments