Skip to content

Commit 0993552

Browse files
committed
Merge pull request #1554 from theideapeople/patch/doc-rule-arrays
Added documentation for validating arrays.
2 parents 7b846be + 6b18fc2 commit 0993552

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

laravel/documentation/validation.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ Now you are familiar with the basic usage of the Validator class. You're ready t
5555
- [E-Mail Addresses](#rule-email)
5656
- [URLs](#rule-url)
5757
- [Uploads](#rule-uploads)
58+
- [Arrays](#rule-arrays)
5859

5960
<a name="rule-required"></a>
6061
### Required
@@ -245,6 +246,29 @@ The *mimes* rule validates that an uploaded file has a given MIME type. This rul
245246

246247
'picture' => 'image|max:100'
247248

249+
<a name="rule-arrays"></a>
250+
### Arrays
251+
252+
#### Validate that an attribute is an array
253+
254+
'categories' => 'array'
255+
256+
#### Validate that an attribute is an array, and has exactly 3 elements
257+
258+
'categories' => 'array|count:3'
259+
260+
#### Validate that an attribute is an array, and has between 1 and 3 elements
261+
262+
'categories' => 'array|countbetween:1,3'
263+
264+
#### Validate that an attribute is an array, and has at least 2 elements
265+
266+
'categories' => 'array|countmin:2'
267+
268+
#### Validate that an attribute is an array, and has at most 2 elements
269+
270+
'categories' => 'array|countmax:2'
271+
248272
<a name="retrieving-error-messages"></a>
249273
## Retrieving Error Messages
250274

@@ -321,11 +345,11 @@ This will also work great when we need to conditionally add classes when using s
321345
For example, if the email address failed validation, we may want to add the "error" class from Bootstrap to our *div class="control-group"* statement.
322346

323347
<div class="control-group {{ $errors->has('email') ? 'error' : '' }}">
324-
348+
325349
When the validation fails, our rendered view will have the appended *error* class.
326350

327351
<div class="control-group error">
328-
352+
329353

330354

331355
<a name="custom-error-messages"></a>

0 commit comments

Comments
 (0)