. */ /** * Doctrine_Validator_Regexp * * @package Doctrine * @subpackage Validator * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @link www.phpdoctrine.com * @since 1.0 * @version $Revision$ * @author Konsta Vesterinen */ class Doctrine_Validator_Regexp { /** * checks if given value satisfies a regular expression * * @param mixed $value * @param mixed $args * @return boolean */ public function validate($value) { if ( ! isset($this->args)) { return true; } if (is_array($this->args)) { foreach ($this->args as $regexp) { if ( ! preg_match($regexp, $value)) { return false; } } return true; } else { if (preg_match($this->args, $value)) { return true; } } return false; } }