Added documentation for validating arrays.
This commit is contained in:
parent
8ff052cbdb
commit
6b18fc2b24
|
@ -55,6 +55,7 @@ ## Validation Rules
|
||||||
- [E-Mail Addresses](#rule-email)
|
- [E-Mail Addresses](#rule-email)
|
||||||
- [URLs](#rule-url)
|
- [URLs](#rule-url)
|
||||||
- [Uploads](#rule-uploads)
|
- [Uploads](#rule-uploads)
|
||||||
|
- [Arrays](#rule-arrays)
|
||||||
|
|
||||||
<a name="rule-required"></a>
|
<a name="rule-required"></a>
|
||||||
### Required
|
### Required
|
||||||
|
@ -245,6 +246,29 @@ #### Validate that a file is no more than a given size in kilobytes:
|
||||||
|
|
||||||
'picture' => 'image|max:100'
|
'picture' => 'image|max:100'
|
||||||
|
|
||||||
|
<a name="rule-arrays"></a>
|
||||||
|
### Arrays
|
||||||
|
|
||||||
|
#### Validate that an attribute is an array
|
||||||
|
|
||||||
|
'categories' => 'array'
|
||||||
|
|
||||||
|
#### Validate that an attribute is an array, and has exactly 3 elements
|
||||||
|
|
||||||
|
'categories' => 'array|count:3'
|
||||||
|
|
||||||
|
#### Validate that an attribute is an array, and has between 1 and 3 elements
|
||||||
|
|
||||||
|
'categories' => 'array|countbetween:1,3'
|
||||||
|
|
||||||
|
#### Validate that an attribute is an array, and has at least 2 elements
|
||||||
|
|
||||||
|
'categories' => 'array|countmin:2'
|
||||||
|
|
||||||
|
#### Validate that an attribute is an array, and has at most 2 elements
|
||||||
|
|
||||||
|
'categories' => 'array|countmax:2'
|
||||||
|
|
||||||
<a name="retrieving-error-messages"></a>
|
<a name="retrieving-error-messages"></a>
|
||||||
## Retrieving Error Messages
|
## Retrieving Error Messages
|
||||||
|
|
||||||
|
@ -321,11 +345,11 @@ ## Validation Walkthrough
|
||||||
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.
|
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.
|
||||||
|
|
||||||
<div class="control-group {{ $errors->has('email') ? 'error' : '' }}">
|
<div class="control-group {{ $errors->has('email') ? 'error' : '' }}">
|
||||||
|
|
||||||
When the validation fails, our rendered view will have the appended *error* class.
|
When the validation fails, our rendered view will have the appended *error* class.
|
||||||
|
|
||||||
<div class="control-group error">
|
<div class="control-group error">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="custom-error-messages"></a>
|
<a name="custom-error-messages"></a>
|
||||||
|
|
Loading…
Reference in New Issue