@@ -55,6 +55,7 @@ Now you are familiar with the basic usage of the Validator class. You're ready t
55
55
- [ E-Mail Addresses] ( #rule-email )
56
56
- [ URLs] ( #rule-url )
57
57
- [ Uploads] ( #rule-uploads )
58
+ - [ Arrays] ( #rule-arrays )
58
59
59
60
<a name =" rule-required " ></a >
60
61
### Required
@@ -245,6 +246,29 @@ The *mimes* rule validates that an uploaded file has a given MIME type. This rul
245
246
246
247
'picture' => 'image|max:100'
247
248
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
+
248
272
<a name =" retrieving-error-messages " ></a >
249
273
## Retrieving Error Messages
250
274
@@ -321,11 +345,11 @@ This will also work great when we need to conditionally add classes when using s
321
345
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.
322
346
323
347
<div class="control-group {{ $errors->has('email') ? 'error' : '' }}">
324
-
348
+
325
349
When the validation fails, our rendered view will have the appended * error* class.
326
350
327
351
<div class="control-group error">
328
-
352
+
329
353
330
354
331
355
<a name =" custom-error-messages " ></a >
0 commit comments