From 6b18fc2b24313a1401756ee4abe88d2861ef0bf3 Mon Sep 17 00:00:00 2001 From: Ken Stanley Date: Mon, 31 Dec 2012 09:22:50 -0500 Subject: [PATCH] Added documentation for validating arrays. --- laravel/documentation/validation.md | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/laravel/documentation/validation.md b/laravel/documentation/validation.md index eacb6625..0ca6fbf0 100644 --- a/laravel/documentation/validation.md +++ b/laravel/documentation/validation.md @@ -55,6 +55,7 @@ ## Validation Rules - [E-Mail Addresses](#rule-email) - [URLs](#rule-url) - [Uploads](#rule-uploads) +- [Arrays](#rule-arrays) ### Required @@ -245,6 +246,29 @@ #### Validate that a file is no more than a given size in kilobytes: 'picture' => 'image|max:100' + +### 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' + ## 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.
- + When the validation fails, our rendered view will have the appended *error* class.
- +