chainedvalidator.class.php

来自「一个用PHP编写的」· PHP 代码 · 共 44 行

PHP
44
字号
<?php	lt_include( PLOG_CLASS_PATH."class/data/validator/validator.class.php" );    /**     * \ingroup Validator     *     * Validator class that allows to make chained validators so that we can validate for more complex	 * rules. The parameter for the constructor is an array of Validator objects that we are going to	 * chain.	 *	 * Internally, this class is not actually going to chain the validators but their rules, one after each	 * other using the Validator::addValidator() method.	 *	 * You can either create your own brand new custom Validator class and add the rules that you need	 * or if you know that some Validator classes are already doing what you need, you can always 	 * chain them by using the ChainedValidator class.	 *	 * Example:	 *	 * <pre>	 *  $val = new ChainedValidator( Array( new StringValidator(),	 *                                      new UsernameValidator());	 *  $result = $val->validate( $value );	 * </pre>     */    class ChainedValidator extends Validator     {        /**         * Constructor of the chained validator         *         * @param validators An array of Validator objects which implement the logic that         * we need         */    	function ChainedValidator( $validators )        {        	$this->Validator();						foreach( $validators as $validator ) {				$this->addValidator( $validator );			}        }    }?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?