Skip to content

Commit d4f5f38

Browse files
ghabriel25ziadoztaylorotwell
authored
feat: [12.x] Adds missing documentation for encoding rule (#10918)
* feat: [12.x] Adds missing documentation for encoding rule * fix the placement * Update validation.md Co-authored-by: Jamie York <ziadoz@gmail.com> * Update validation.md --------- Co-authored-by: Jamie York <ziadoz@gmail.com> Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent 4241f13 commit d4f5f38

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

validation.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,6 +1075,7 @@ Below is a list of all available validation rules and their function:
10751075

10761076
[Between](#rule-between)
10771077
[Dimensions](#rule-dimensions)
1078+
[Encoding](#rule-encoding)
10781079
[Extensions](#rule-extensions)
10791080
[File](#rule-file)
10801081
[Image](#rule-image)
@@ -1575,6 +1576,24 @@ $request->validate([
15751576
> [!WARNING]
15761577
> The `dns` and `spoof` validators require the PHP `intl` extension.
15771578
1579+
<a name="rule-encoding"></a>
1580+
#### encoding:*encoding_type*
1581+
1582+
The field under validation must match the specified character encoding. This rule uses PHP's `mb_check_encoding` function to verify the encoding of the given file or string value. For convenience, the `encoding` rule may be constructed using Laravel's fluent file rule builder:
1583+
1584+
```php
1585+
use Illuminate\Support\Facades\Validator;
1586+
use Illuminate\Validation\Rules\File;
1587+
1588+
Validator::validate($input, [
1589+
'attachment' => [
1590+
'required',
1591+
File::types(['csv'])
1592+
->encoding('utf-8'),
1593+
],
1594+
]);
1595+
```
1596+
15781597
<a name="rule-ends-with"></a>
15791598
#### ends_with:_foo_,_bar_,...
15801599

0 commit comments

Comments
 (0)