Skip to content

Commit 84f56ee

Browse files
committed
Update validation.md
1 parent d262a82 commit 84f56ee

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

validation.md

+19-6
Original file line numberDiff line numberDiff line change
@@ -2106,6 +2106,22 @@ Laravel provides a variety of validation rules that may be used to validate uplo
21062106
],
21072107
]);
21082108

2109+
2110+
<a name="validating-files-file-sizes"></a>
2111+
#### File Sizes
2112+
2113+
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.
2114+
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:
2115+
2116+
```php
2117+
File::types(['mp3', 'wav'])
2118+
->min('1kb')
2119+
->max('10mb');
2120+
```
2121+
2122+
<a name="validating-files-image-files"></a>
2123+
#### Validating Image Files
2124+
21092125
If your application accepts images uploaded by your users, you may use the `File` rule's `image` constructor method to indicate that the uploaded file should be an image.
21102126

21112127
use Illuminate\Support\Facades\Validator;
@@ -2125,16 +2141,13 @@ The `File::image()` rule makes sure that the file under validation must be an im
21252141
> By default the File::image() rule does not allow SVG files due to possible XSS attacks.
21262142
> 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.
21272143
2128-
<a name="validating-files-file-sizes-and-dimensions"></a>
2129-
#### File Sizes & Dimensions
2144+
<a name="validating-files-image-dimensions"></a>
2145+
#### Validating Image Dimensions
21302146

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.
2132-
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:
2147+
You may 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:
21332148

21342149
```php
21352150
File::image()
2136-
->min('1kb')
2137-
->max('10mb')
21382151
->dimensions(Rule::dimensions()->maxWidth(1000)->maxHeight(500))
21392152
```
21402153

0 commit comments

Comments
 (0)