Skip to content

Commit d262a82

Browse files
committed
Update validation.md
1 parent 54b0b0c commit d262a82

File tree

1 file changed

+7
-22
lines changed

1 file changed

+7
-22
lines changed

validation.md

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2125,37 +2125,22 @@ The `File::image()` rule makes sure that the file under validation must be an im
21252125
> By default the File::image() rule does not allow SVG files due to possible XSS attacks.
21262126
> If you need to allow SVG files, you can pass `allowSvg: true` as argument, e.g. `File::image(allowSvg: true)` and handle potentially unsafe SVG files manually.
21272127
2128-
<a name="validating-files-file-sizes"></a>
2129-
#### File Dimensions
2128+
<a name="validating-files-file-sizes-and-dimensions"></a>
2129+
#### File Sizes & Dimensions
21302130

2131+
For convenience, minimum and maximum file sizes may be specified as a string with a suffix indicating the file size units. The `kb`, `mb`, `gb`, and `tb` suffixes are supported.
21312132
You may also validate the dimensions of an image. For example, to validate that an uploaded image is at least 1000 pixels wide and 500 pixels tall, you may use the `dimensions` rule:
21322133

2133-
use Illuminate\Support\Facades\Validator;
2134-
use Illuminate\Validation\Rule;
2135-
use Illuminate\Validation\Rules\File;
2136-
2137-
Validator::validate($input, [
2138-
'photo' => [
2139-
'required',
2140-
File::image()
2141-
->dimensions(Rule::dimensions()->maxWidth(1000)->maxHeight(500)),
2142-
],
2143-
]);
2144-
2145-
> [!NOTE]
2146-
> More information regarding validating image dimensions may be found in the [dimension rule documentation](#rule-dimensions).
2147-
2148-
<a name="validating-files-file-sizes"></a>
2149-
#### File Sizes
2150-
2151-
For convenience, minimum and maximum file sizes may be specified as a string with a suffix indicating the file size units. The `kb`, `mb`, `gb`, and `tb` suffixes are supported:
2152-
21532134
```php
21542135
File::image()
21552136
->min('1kb')
21562137
->max('10mb')
2138+
->dimensions(Rule::dimensions()->maxWidth(1000)->maxHeight(500))
21572139
```
21582140

2141+
> [!NOTE]
2142+
> More information regarding validating image dimensions may be found in the [dimension rule documentation](#rule-dimensions).
2143+
21592144
<a name="validating-files-file-types"></a>
21602145
#### File Types
21612146

0 commit comments

Comments
 (0)