TYPO3 API  SVNRelease
ConjunctionValidator.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
00006 *  All rights reserved
00007 *
00008 *  This class is a backport of the corresponding class of FLOW3.
00009 *  All credits go to the v5 team.
00010 *
00011 *  This script is part of the TYPO3 project. The TYPO3 project is
00012 *  free software; you can redistribute it and/or modify
00013 *  it under the terms of the GNU General Public License as published by
00014 *  the Free Software Foundation; either version 2 of the License, or
00015 *  (at your option) any later version.
00016 *
00017 *  The GNU General Public License can be found at
00018 *  http://www.gnu.org/copyleft/gpl.html.
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00027 
00028 /**
00029  * Validator to chain many validators in a conjunction (logical and). So every
00030  * validator has to be valid, to make the whole conjunction valid.
00031  *
00032  * @package Extbase
00033  * @subpackage Validation\Validator
00034  * @version $Id: ConjunctionValidator.php 1729 2009-11-25 21:37:20Z stucki $
00035  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
00036  * @scope prototype
00037  */
00038 class Tx_Extbase_Validation_Validator_ConjunctionValidator extends Tx_Extbase_Validation_Validator_AbstractCompositeValidator {
00039     /**
00040      * Checks if the given value is valid according to the validators of the conjunction.
00041      *
00042      * If at least one error occurred, the result is FALSE.
00043      *
00044      * @param mixed $value The value that should be validated
00045      */
00046     public function isValid($value) {
00047         $result = TRUE;
00048         foreach ($this->validators as $validator) {
00049             if ($validator->isValid($value) === FALSE) {
00050                 $this->errors = array_merge($this->errors, $validator->getErrors());
00051                 $result = FALSE;
00052             }
00053         }
00054         return $result;
00055     }
00056 }
00057 
00058 ?>