* * * * * * * * @author Michael Aichler * @author Hans Lellelid * @version $Revision: 1612 $ * @package propel.runtime.validator */ class NotMatchValidator implements BasicValidator { /** * Prepares the regular expression entered in the XML * for use with preg_match(). * @param string $exp * @return string Prepared regular expession. */ private function prepareRegexp($exp) { // remove surrounding '/' marks so that they don't get escaped in next step if ($exp{0} !== '/' || $exp{strlen($exp)-1} !== '/' ) { $exp = '/' . $exp . '/'; } // if they did not escape / chars; we do that for them $exp = preg_replace('/([^\\\])\/([^$])/', '$1\/$2', $exp); return $exp; } /** * Whether the passed string matches regular expression. */ public function isValid (ValidatorMap $map, $str) { return (preg_match($this->prepareRegexp($map->getValue()), $str) == 0); } }