/** * Validates a value using a regular expression * * @param string $value Value to be checked * @param string $pattern A format from Date_Local. Leave NULL to use $this->pattern. * @return boolean true if $value is valid */ function validate($value, $pattern = null) { if ($value === null || $value === "") { return null; } if (!isset($pattern) && (!isset($this) || !$this instanceof self)) { $pattern = parent::getRegex('time'); } if (isset($pattern)) { $pattern = self::getRegex($pattern); } if (is_int($value) && (isset($pattern) ? $pattern : $this->pattern)) { return !$this->negate; } return parent::validate($value, $pattern); }