✏️ 编辑:sfValidatorRegex.class.php
路径:
/virtual/bigbrother/sns/lib/symfony/validator/sfValidatorRegex.class.php
大小:1.31 KB · 修改:2010-08-11 06:11:37 · 权限:0644 · 可写
← 返回目录
👁 查看
⬇ 下载
<?php /* * This file is part of the symfony package. * (c) Fabien Potencier <fabien.potencier@symfony-project.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * sfValidatorRegex validates a value with a regular expression. * * @package symfony * @subpackage validator * @author Fabien Potencier <fabien.potencier@symfony-project.com> * @version SVN: $Id: sfValidatorRegex.class.php 12081 2008-10-08 19:01:19Z fabien $ */ class sfValidatorRegex extends sfValidatorString { /** * Configures the current validator. * * Available options: * * * pattern: A regex pattern compatible with PCRE (required) * * @param array $options An array of options * @param array $messages An array of error messages * * @see sfValidatorString */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $this->addRequiredOption('pattern'); } /** * @see sfValidatorString */ protected function doClean($value) { $clean = parent::doClean($value); if (!preg_match($this->getOption('pattern'), $clean)) { throw new sfValidatorError($this, 'invalid', array('value' => $value)); } return $clean; } }
💾 保存
取消
保存为 UTF-8,换行统一为 LF