From 3b45d62d6c0dd80615e643640f85c0d0bc0e4603 Mon Sep 17 00:00:00 2001 From: bzy107 Date: Wed, 29 May 2024 00:00:21 +0900 Subject: [PATCH] docs: add custom import file validation document --- .../docs/07-prebuilt-actions/08-import.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/packages/actions/docs/07-prebuilt-actions/08-import.md b/packages/actions/docs/07-prebuilt-actions/08-import.md index fa84efea03..a373ecdf1f 100644 --- a/packages/actions/docs/07-prebuilt-actions/08-import.md +++ b/packages/actions/docs/07-prebuilt-actions/08-import.md @@ -707,6 +707,25 @@ ImportColumn::make('name') ->validationAttribute('full name') ``` +## Customizing Import File Validation + +You can add the `fileRules()` method to implement validation for file uploads. + +```php +ImportAction::make() + ->importer(ProductImporter::class) + ->fileRules( + [ + 'max:1024', + + // or + + File::types(['csv', 'text']) + ->max(1024), + ] + ), +``` + ## Lifecycle hooks Hooks may be used to execute code at various points within an importer's lifecycle, like before a record is saved. To set up a hook, create a protected method on the importer class with the name of the hook: