/** * 载入扩展校验器 * * @param YUN_Validator_Extension_Abstract $extension * @return YUN_Validator * @throws Exception */ public function loadExtension(YUN_Validator_Extension_Abstract $extension) { $processor = $extension->registerProcessor(); foreach ($processor as $format => $method) { if (isset($this->_processor[$format])) { throw new Exception("校验类型 '{$format}' 已存在"); } else { $this->_processor[$format] = $method; } } return $this; }
/** * 注册校验处理器 * * @return array */ public function registerProcessor() { $processor = parent::registerProcessor(); $exts = array('Numeric' => 'is_numeric', 'Array' => 'is_array', 'InArray' => 'in_array', 'Alpha' => 'ctype_alpha', 'Hex' => 'ctype_xdigit'); return array_merge($processor, $exts); }