| 1 |
171
|
jakob |
<?php |
|
| 2 |
↓
|
jakob |
/** |
|
| 3 |
↓
|
jakob |
* phpillow CouchDB backend |
|
| 4 |
↓
|
jakob |
* |
|
| 5 |
↓
|
jakob |
* This file is part of phpillow. |
|
| 6 |
↓
|
jakob |
* |
|
| 7 |
↓
|
jakob |
* phpillow is free software; you can redistribute it and/or modify it under |
|
| 8 |
↓
|
jakob |
* the terms of the GNU Lesser General Public License as published by the Free |
|
| 9 |
↓
|
jakob |
* Software Foundation; version 3 of the License. |
|
| 10 |
↓
|
jakob |
* |
|
| 11 |
↓
|
jakob |
* phpillow is distributed in the hope that it will be useful, but WITHOUT ANY |
|
| 12 |
↓
|
jakob |
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
| 13 |
↓
|
jakob |
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
|
| 14 |
↓
|
jakob |
* more details. |
|
| 15 |
↓
|
jakob |
* |
|
| 16 |
↓
|
jakob |
* You should have received a copy of the GNU Lesser General Public License |
|
| 17 |
↓
|
jakob |
* along with phpillow; if not, write to the Free Software Foundation, Inc., 51 |
|
| 18 |
↓
|
jakob |
* Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|
| 19 |
↓
|
jakob |
* |
|
| 20 |
↓
|
jakob |
* @package Core |
|
| 21 |
↓
|
jakob |
* @version $Revision: 171 $ |
|
| 22 |
↓
|
jakob |
* @license http://www.gnu.org/licenses/lgpl-3.0.txt LGPL |
|
| 23 |
↓
|
jakob |
*/ |
|
| 24 |
↓
|
jakob |
|
|
| 25 |
↓
|
jakob |
/** |
|
| 26 |
↓
|
jakob |
* Validate arrays of object inputs |
|
| 27 |
↓
|
jakob |
* |
|
| 28 |
↓
|
jakob |
* @package Core |
|
| 29 |
↓
|
jakob |
* @version $Revision: 171 $ |
|
| 30 |
↓
|
jakob |
* @license http://www.gnu.org/licenses/lgpl-3.0.txt LGPL |
|
| 31 |
↓
|
jakob |
*/ |
|
| 32 |
↓
|
jakob |
class phpillowObjectArrayValidator extends phpillowObjectValidator |
|
| 33 |
↓
|
jakob |
{ |
|
| 34 |
↓
|
jakob |
/** |
|
| 35 |
↓
|
jakob |
* Validate input to be an array of objects |
|
| 36 |
↓
|
jakob |
* |
|
| 37 |
↓
|
jakob |
* @param array $input |
|
| 38 |
↓
|
jakob |
* @return array |
|
| 39 |
↓
|
jakob |
*/ |
|
| 40 |
↓
|
jakob |
public function validate( $input ) |
|
| 41 |
↓
|
jakob |
{ |
|
| 42 |
↓
|
jakob |
if ( !is_array( $input ) ) |
|
| 43 |
↓
|
jakob |
{ |
|
| 44 |
↓
|
jakob |
throw new phpillowValidationException( |
|
| 45 |
↓
|
jakob |
"Field is not an array", |
|
| 46 |
↓
|
jakob |
array() |
|
| 47 |
↓
|
jakob |
); |
|
| 48 |
↓
|
jakob |
} |
|
| 49 |
↓
|
jakob |
|
|
| 50 |
↓
|
jakob |
// Reuse the parent object validator foreach of the embedded objects |
|
| 51 |
↓
|
jakob |
foreach( $input as $key => $object ) |
|
| 52 |
↓
|
jakob |
{ |
|
| 53 |
↓
|
jakob |
$input[$key] = parent::validate( $object ); |
|
| 54 |
↓
|
jakob |
} |
|
| 55 |
↓
|
jakob |
|
|
| 56 |
↓
|
jakob |
return $input; |
|
| 57 |
↓
|
jakob |
} |
|
| 58 |
↓
|
jakob |
} |
|