Source for file Validator.php
Documentation is available at Validator.php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
* Created on 10. Feb. 2007 by Norman Markgraf (nmarkgraf(at)user.sourceforge.net)
* This class will have several static methods to check if a input string is of
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* This software consists of voluntary contributions made by many individuals
* and is licensed under the GPL. For more information please see
* <http://opendocumentphp.org>.
* $Id: Validator.php 260 2007-08-03 13:42:29Z nmarkgraf $
* @package OpenDocumentPHP
* @author Norman Markgraf (nmarkgraf(at)user.sourceforge.net)
* @copyright Copyright in 2006, 2007 by The OpenDocumentPHP Team
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License 2.0.
* @version SVN: $Id: Validator.php 260 2007-08-03 13:42:29Z nmarkgraf $
* @link http://opendocumentphp.org
* @link http://www.oasis-open.org/committees/download.php/20493/UCR.pdf OpenDocument Metadata Use Cases and Requirements
* @since 0.5.1 - 10. Feb. 2007
* This class will have several static methods to check if a input string is of
* Most of the definition is reight out of the original RelaxNG schemata for
* We use Regular Expression Functions (Perl-Compatible) aka <i>PCRE</i> in this Validator
* class. Beginning with PHP 4.2.0 these functions are enabled by default. You can disable
* the PCRE functions with --without-pcre-regex. Use --with-pcre-regex=DIR to specify DIR
* where PCRE's include and library files are located, if not using bundled library.
* For older versions you have to configure and compile PHP with --with-pcre-regex[=DIR]
* in order to use these functions.
* The windows version of PHP has built in support for this extension. You do not need to
* load any additional extension in order to use these functions.
* @package OpenDocumentPHP
* @author Norman Markgraf (nmarkgraf(at)user.sourceforge.net)
* @copyright Copyright in 2006, 2007 by OpenDocumentPHP Team
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License 2.0.
* @version Release: @package_version@
* @link http://opendocumentphp.org
* @since 0.5.1 - 10. Feb. 2007
* Checks if the input is a positive integer (input > 0).
* @param mixed $input Input which is been testet.
* @return bool Is true, only if it is a positive integer.
* @since 0.5.1 - 10. Feb. 2007
return ((int) $input > 0);
* Checks if the input is a integer.
* @param mixed $input Input which is been testet.
* @return bool Is true, only if it is a positive integer.
* @since 0.5.1 - 10. Feb. 2007
* Checks if the input string is 'non-colonized name' (NCName).
* @param mixed $input Input which is been tested.
* @return bool Is true, only if $input is a non-colonized name.
* @since 0.5.1 - 10. Feb. 2007
preg_match('/^([a-zA-z_])(([a-zA-Z0-9]|-|_|\.)*)$/', $input)) {
* Checks if the input string is of "styleNameRef" type. Which is eigther
* a NCName string or empty.
* @param mixed $input Input which is been tested.
* @return bool Is true, only if $input is of "styleNameRef" type.
* @since 0.5.1 - 10. Feb. 2007
* Checks if the input string represents a color, like #00FF00 is green.
* @since 0.5.1 - 10. Feb. 2007
static public function isColor($input)
* Checks if the input is a positiveLength.
* @since 0.5.1 - 10. Feb. 2007
preg_match('/^([0-9]*[1-9][0-9]*(\.[0-9]*)?|0+\.[0-9]*[1-9][0-9]*|\.[0-9]*[1-9][0-9]*)((cm)|(mm)|(in)|(pt)|(pc)|(px))$/', $input)) {
* Checks if the input is a family value.
* @since 0.5.2 - 19. Mar. 2007
|