Task #6727 » DisjunctionValidator.diff

Lukas Lentner, 2010-03-07 17:33

View differences:

DisjunctionValidator.php 2010-03-07 17:31:22.000000000 +0100
34 34
 */
35 35
class DisjunctionValidator extends \F3\FLOW3\Validation\Validator\AbstractCompositeValidator {
36 36
	/**
37
	 * Checks if the given value is valid according to the validators of the conjunction.
37
	 * Checks if the given value is valid according to the validators of the disjunction.
38 38
	 *
39
	 * If at least one error occurred, the result is FALSE.
39
	 * If all validators fail, the result is FALSE.
40 40
	 *
41 41
	 * @param mixed $value The value that should be validated
42
	 * @return boolean TRUE if the value is valid, FALSE if an error occured
42
	 * @return boolean TRUE if at least one validator valid, FALSE if all validators fail
43 43
	 * @author Robert Lemke <robert@typo3.org>
44 44
	 * @author Christopher Hlubek <hlubek@networkteam.com>
45
	 * @author Lukas Lentner <lukaslentner@web.de>
45 46
	 * @api
46 47
	 */
47 48
	public function isValid($value) {
48
		$result = FALSE;
49 49
		foreach ($this->validators as $validator) {
50 50
			if ($validator->isValid($value) === FALSE) {
51 51
				$this->errors = array_merge($this->errors, $validator->getErrors());
52 52
			} else {
53
				$result = TRUE;
53
				$this->errors = array();
54
				return TRUE;
54 55
			}
55 56
		}
56
		if ($result === TRUE) {
57
			$this->errors = array();
58
		}
59
		return $result;
57
		return FALSE;
60 58
	}
61 59
}
62 60

  
63
?>
61
?>
(2-2/2)