• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP sfValidatorBase类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中sfValidatorBase的典型用法代码示例。如果您正苦于以下问题:PHP sfValidatorBase类的具体用法?PHP sfValidatorBase怎么用?PHP sfValidatorBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了sfValidatorBase类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: clean

 private function clean(sfValidatorBase $v, $value)
 {
     $this->result = 'true';
     try {
         $v->clean($value);
     } catch (Exception $e) {
         $this->result = 'false';
     }
     $this->renderText($this->result);
 }
开发者ID:limitium,项目名称:uberlov,代码行数:10,代码来源:actions.class.php


示例2: configure

 public function configure()
 {
     sfValidatorBase::setDefaultMessage('required', __('GENERAL_REQUIRED_FIELD_ERROR'));
     sfValidatorBase::setDefaultMessage('min_length', sprintf(__('GENERAL_FIELD_TOO_SHORT_ERROR'), '"%value%"', '%min_length%'));
     $items = PcTimezonePeer::doSelect(new Criteria());
     $tzs = array();
     foreach ($items as $item) {
         $tzs[$item->getLabel()] = $item->getDescription();
     }
     $this->setWidgets(array('email' => new sfWidgetFormInputText(), 'password1' => new sfWidgetFormInputPassword(), 'password2' => new sfWidgetFormInputPassword(), 'lang' => new sfWidgetFormInputHidden(), 'tz' => new sfWidgetFormInputHidden(array('default' => self::TIMEZONE_DEFAULT_VALUE)), 'dst_on' => new sfWidgetFormInputHidden(array('default' => 0))));
     $this->setValidators(array('password1' => new sfValidatorString(array('max_length' => sfConfig::get('app_password_maxLength'), 'min_length' => sfConfig::get('app_password_minLength'))), 'password2' => new sfValidatorString(array('max_length' => sfConfig::get('app_password_maxLength'), 'min_length' => sfConfig::get('app_password_minLength'))), 'tz' => new sfValidatorString(), 'lang' => new sfValidatorString(array('max_length' => 8, 'required' => false)), 'dst_on' => new sfValidatorString(array('max_length' => 1))));
     $emailDomainsBlacklistedInRegistration = sfConfig::get('app_site_emailDomainsBlacklistedInRegistration');
     foreach ($emailDomainsBlacklistedInRegistration as $k => $v) {
         $emailDomainsBlacklistedInRegistration[$k] = str_replace('.', '\\.', $v);
     }
     $emailDomainsBlacklistedInRegistration = implode('|', $emailDomainsBlacklistedInRegistration);
     $this->validatorSchema['email'] = new sfValidatorAnd(array(new sfValidatorEmail(array('required' => true, 'max_length' => sfConfig::get('app_email_maxLength'), 'min_length' => sfConfig::get('app_email_minLength'))), new sfValidatorRegex(array('pattern' => '/@(' . $emailDomainsBlacklistedInRegistration . ')(\\b|$)/si', 'must_match' => false), array('invalid' => 'Domain blocked - please use another email'))), array(), array());
     $this->mergePostValidator(new sfValidatorSchemaCompare('password1', '==', 'password2', array(), array('invalid' => __('WEBSITE_REGISTRATION_PASSWORD_MISMATCH_ERROR'))));
     $this->mergePostValidator(new sfValidatorDetectingSpammersOnRegistration(null, array(), array('invalid' => __('WEBSITE_REGISTRATION_PASSWORD_MISMATCH_ERROR'))));
     $this->widgetSchema->setLabels(array('email' => __('WEBSITE_REGISTRATION_EMAIL_ADDRESS_LABEL'), 'password1' => __('WEBSITE_REGISTRATION_CHOOSE_PASSWORD_LABEL'), 'password2' => __('WEBSITE_REGISTRATION_REPEAT_PASSWORD_LABEL')));
     $this->widgetSchema->setNameFormat('registration[%s]');
     // {{{ START: anti-spam (see sfValidatorTimerAntiSpam class)
     $this->widgetSchema['asdf'] = new sfWidgetFormInputHidden(array(), array('value' => base64_encode(time())));
     $this->validatorSchema['asdf'] = new sfValidatorTimerAntiSpam();
     // }}} STOP: anti-spam
 }
开发者ID:ntemple,项目名称:intelli-plancake,代码行数:26,代码来源:RegistrationForm.class.php


示例3: doAskAndValidate

 /**
  * @see askAndValidate()
  */
 public static function doAskAndValidate(sfTask $task, $question, sfValidatorBase $validator, array $options = array())
 {
     if (!is_array($question)) {
         $question = array($question);
     }
     $options = array_merge(array('value' => null, 'attempts' => 3, 'style' => 'QUESTION'), $options);
     while ($options['attempts']--) {
         $value = is_null($options['value']) ? $task->ask(isset($error) && 'required' != $error->getCode() ? array_merge(array($error->getMessage(), ''), $question) : $question, isset($error) ? 'ERROR' : $options['style']) : $options['value'];
         try {
             $value = $validator->clean($value);
             return $value;
         } catch (sfValidatorError $error) {
             $value = null;
         }
     }
     throw $error;
 }
开发者ID:jmiridis,项目名称:atcsf1,代码行数:20,代码来源:sfTaskExtraBaseTask.class.php


示例4: configure

 public function configure()
 {
     sfValidatorBase::setDefaultMessage('required', __('GENERAL_REQUIRED_FIELD_ERROR'));
     sfValidatorBase::setDefaultMessage('min_length', sprintf(__('GENERAL_FIELD_TOO_SHORT_ERROR'), '"%value%"', '%min_length%'));
     $this->setWidgets(array('email' => new sfWidgetFormInput(), 'return-url' => new sfWidgetFormInputHidden(), 'password' => new sfWidgetFormInputPassword(), 'rememberme' => new sfWidgetFormInputCheckbox(array())));
     $this->setValidators(array('email' => new sfValidatorEmail(array('required' => true, 'max_length' => sfConfig::get('app_email_maxLength'), 'min_length' => sfConfig::get('app_email_minLength')), array('invalid' => __('WEBSITE_LOGIN_EMAIL_ERROR'))), 'password' => new sfValidatorString(array('max_length' => sfConfig::get('app_password_maxLength'), 'min_length' => sfConfig::get('app_password_minLength'))), 'rememberme' => new sfValidatorBoolean(array('required' => false)), 'return-url' => new sfValidatorString(array('required' => false))));
     $this->widgetSchema->setLabels(array('email' => __('WEBSITE_LOGIN_EMAIL_LABEL'), 'password' => __('WEBSITE_LOGIN_PASSWORD_LABEL'), 'rememberme' => __('WEBSITE_LOGIN_REMEMBER_ME_LABEL')));
     $this->widgetSchema->setNameFormat('login[%s]');
 }
开发者ID:ntemple,项目名称:intelli-plancake,代码行数:9,代码来源:LoginForm.class.php


示例5: configure

 public function configure()
 {
     sfValidatorBase::setDefaultMessage('required', __('GENERAL_REQUIRED_FIELD_ERROR'));
     sfValidatorBase::setDefaultMessage('min_length', sprintf(__('GENERAL_FIELD_TOO_SHORT_ERROR'), '"%value%"', '%min_length%'));
     $this->setWidgets(array('username' => new sfWidgetFormInputText(), 'return-url' => new sfWidgetFormInputHidden()));
     $this->setValidators(array('username' => new sfValidatorString(array('required' => true, 'max_length' => sfConfig::get('app_username_maxLength'), 'min_length' => sfConfig::get('app_username_minLength'))), 'return-url' => new sfValidatorString(array('required' => false))));
     $this->widgetSchema->setLabels(array('username' => __('WEBSITE_FORUM_USERNAME_USERNAME_LABEL')));
     $this->widgetSchema->setNameFormat('chooseUsername[%s]');
 }
开发者ID:ntemple,项目名称:intelli-plancake,代码行数:9,代码来源:ChooseUsernameForm.class.php


示例6: configure

 /**
  * Configures the current validator.
  *
  * Available options:
  *
  *  * from_time:   The from time validator (required)
  *  * to_time:     The to time validator (required)
  *  * from_field:  The name of the "from" date field (optional, default: from)
  *  * to_field:    The name of the "to" date field (optional, default: to)
  *
  * @param array $options    An array of options
  * @param array $messages   An array of error messages
  *
  * @see sfValidatorBase
  */
 protected function configure($options = array(), $messages = array())
 {
     parent::configure($options, $messages);
     $this->setMessage('invalid', 'From time should be before to time.');
     $this->addRequiredOption('from_time');
     $this->addRequiredOption('to_time');
     $this->addOption('from_field', 'from');
     $this->addOption('to_field', 'to');
 }
开发者ID:lahirwisada,项目名称:orangehrm,代码行数:24,代码来源:ohrmValidatorTimeRange.php


示例7: configure

 public function configure()
 {
     sfValidatorBase::setDefaultMessage('required', __('GENERAL_REQUIRED_FIELD_ERROR'));
     sfValidatorBase::setDefaultMessage('min_length', sprintf(__('GENERAL_FIELD_TOO_SHORT_ERROR'), '"%value%"', '%min_length%'));
     $this->setWidgets(array('email' => new sfWidgetFormInput()));
     $this->setValidators(array('email' => new sfValidatorEmail(array('required' => true), array('invalid' => __('WEBSITE_FORGOTTEN_PSW_EMAIL_ERROR')))));
     $this->widgetSchema->setLabels(array('email' => __('WEBSITE_FORGOTTEN_PSW_EMAIL_LABEL')));
     $this->widgetSchema->setNameFormat('passwordForgotten[%s]');
 }
开发者ID:ntemple,项目名称:intelli-plancake,代码行数:9,代码来源:PasswordForgottenForm.class.php


示例8: setup

 public function setup()
 {
     sfConfig::set('linguagens', array('csharp' => 'C#', 'css' => 'CSS', 'gettext' => 'Gettext', 'groovy' => 'Groovy', 'haskell' => 'Haskell', 'html4strict' => 'HTML', 'java' => 'Java', 'java5' => 'Java 5', 'javascript' => 'JavaScript', 'jquery' => 'jQuery', 'mirc' => 'mIRC', 'mysql' => 'MySQL', 'objc' => 'Objective C', 'php' => 'PHP', 'plsql' => 'PL/SQL', 'properties' => 'Properties', 'python' => 'Python', 'rails' => 'Rails', 'ruby' => 'Ruby', 'scala' => 'Scala', 'sql' => 'SQL', 'text' => 'Texto puro', 'xml' => 'XML'));
     sfValidatorBase::setDefaultMessage('required', 'Campo obrigatório');
     sfValidatorBase::setDefaultMessage('invalid', 'Campo inválido');
     $this->enablePlugins('sfDoctrinePlugin');
     $this->enablePlugins('sfGeshiPlugin');
     $this->enablePlugins('sfDoctrineActAsTaggablePlugin');
 }
开发者ID:hisamu,项目名称:snippets,代码行数:9,代码来源:ProjectConfiguration.class.php


示例9: configure

 public function configure()
 {
     sfValidatorBase::setDefaultMessage('required', __('GENERAL_REQUIRED_FIELD_ERROR'));
     sfValidatorBase::setDefaultMessage('min_length', sprintf(__('GENERAL_FIELD_TOO_SHORT_ERROR'), '"%value%"', '%min_length%'));
     $this->setWidgets(array('password1' => new sfWidgetFormInputPassword(), 'password2' => new sfWidgetFormInputPassword()));
     $this->setValidators(array('password1' => new sfValidatorString(array('max_length' => sfConfig::get('app_password_maxLength'), 'min_length' => sfConfig::get('app_password_minLength'))), 'password2' => new sfValidatorString(array('max_length' => sfConfig::get('app_password_maxLength'), 'min_length' => sfConfig::get('app_password_minLength')))));
     $this->mergePostValidator(new sfValidatorSchemaCompare('password1', '==', 'password2', array(), array('invalid' => __('ACCOUNT_SETTINGS_PASSWORDS_DONT_MATCH_ERROR'))));
     $this->widgetSchema->setLabels(array('password1' => __('ACCOUNT_SETTINGS_PASSWORD'), 'password2' => __('ACCOUNT_SETTINGS_REPEAT_PASSWORD')));
     $this->widgetSchema->setNameFormat('password[%s]');
 }
开发者ID:ntemple,项目名称:intelli-plancake,代码行数:10,代码来源:EditPasswordForm.class.php


示例10: setup

 public function setup()
 {
     $this->enablePlugins('sfDoctrinePlugin');
     //provisorio
     sfValidatorBase::setDefaultMessage('required', 'Campo obrigatório');
     sfValidatorBase::setDefaultMessage('invalid', 'Campo inválido');
     $this->enablePlugins('doAuthPlugin');
     $this->enablePlugins('sfCKEditorPlugin');
     $this->enablePlugins('sfFormExtraPlugin');
 }
开发者ID:kidh0,项目名称:TCControl,代码行数:10,代码来源:ProjectConfiguration.class.php


示例11: configure

 public function configure()
 {
     sfValidatorBase::setDefaultMessage('required', __('GENERAL_REQUIRED_FIELD_ERROR'));
     sfValidatorBase::setDefaultMessage('min_length', sprintf(__('GENERAL_FIELD_TOO_SHORT_ERROR'), '"%value%"', '%min_length%'));
     $this->setWidgets(array('email1' => new sfWidgetFormInputText(), 'email2' => new sfWidgetFormInputText()));
     $this->setValidators(array('email1' => new sfValidatorEmail(array('required' => true, 'max_length' => sfConfig::get('app_email_maxLength'), 'min_length' => sfConfig::get('app_email_minLength')), array('invalid' => __('ACCOUNT_SETTINGS_INVALID_EMAIL_ERROR'))), 'email2' => new sfValidatorEmail(array('required' => true, 'max_length' => sfConfig::get('app_email_maxLength'), 'min_length' => sfConfig::get('app_email_minLength')), array('invalid' => __('ACCOUNT_SETTINGS_INVALID_EMAIL_ERROR')))));
     $this->mergePostValidator(new sfValidatorSchemaCompare('email1', '==', 'email2', array(), array('invalid' => __('ACCOUNT_SETTINGS_EMAILS_DONT_MATCH_ERROR'))));
     $this->widgetSchema->setLabels(array('email1' => __('ACCOUNT_SETTINGS_EMAIL'), 'email2' => __('ACCOUNT_SETTINGS_REPEAT_EMAIL')));
     $this->widgetSchema->setNameFormat('email[%s]');
 }
开发者ID:ntemple,项目名称:intelli-plancake,代码行数:10,代码来源:EditEmailForm.class.php


示例12: setup

 public function setup()
 {
     $this->setWebDir($this->getRootDir());
     $this->enablePlugins('sfDoctrinePlugin');
     $this->enablePlugins('tsUploadPlugin');
     sfValidatorBase::setDefaultMessage('required', 'Не должно быть пустым');
     sfValidatorBase::setDefaultMessage('invalid', 'Введите корректное значение');
     $this->enablePlugins('sfJqueryReloadedPlugin');
     $this->enablePlugins('sfAdminDashPlugin');
     $this->enablePlugins('sfCKEditorPlugin');
 }
开发者ID:rollmax,项目名称:read2read,代码行数:11,代码来源:ProjectConfiguration.class.php


示例13: configure

 public function configure()
 {
     sfValidatorBase::setDefaultMessage('required', __('GENERAL_REQUIRED_FIELD_ERROR'));
     sfValidatorBase::setDefaultMessage('min_length', sprintf(__('GENERAL_FIELD_TOO_SHORT_ERROR'), '"%value%"', '%min_length%'));
     $this->setWidgets(array('file' => new sfWidgetFormInputFile()));
     $this->widgetSchema->setNameFormat('avatar[%s]');
     $this->setValidators(array('file' => new sfValidatorFile()));
     $validMimeTypes = array('image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png', 'image/gif');
     $this->validatorSchema['file']->setOption('mime_types', $validMimeTypes);
     $this->validatorSchema['file']->setOption('max_size', sfConfig::get('app_avatar_maxSize'));
     $messages = array('invalid' => 'Invalid file.', 'required' => 'Select a file to upload.', 'max_size' => 'The file can\'t be bigger than ' . sfConfig::get('app_avatar_maxSize') / 1000000 . 'MB', 'mime_types' => 'The file must be of JPEG, PNG , GIF format.');
     $this->validatorSchema['file']->setMessages($messages);
 }
开发者ID:ntemple,项目名称:intelli-plancake,代码行数:13,代码来源:UploadAvatarForm.class.php


示例14: __construct

 /**
  * Constructor.
  *
  * The first argument can be:
  *
  *  * null
  *  * an array of named sfValidatorBase instances
  *
  * @param mixed $fields    Initial fields
  * @param array $options   An array of options
  * @param array $messages  An array of error messages
  *
  * @see sfValidatorBase
  */
 public function __construct($fields = null, $options = array(), $messages = array())
 {
     if (is_array($fields)) {
         foreach ($fields as $name => $validator) {
             $this[$name] = $validator;
         }
     } else {
         if (null !== $fields) {
             throw new InvalidArgumentException('sfValidatorSchema constructor takes an array of sfValidatorBase objects.');
         }
     }
     parent::__construct($options, $messages);
 }
开发者ID:Phennim,项目名称:symfony1,代码行数:27,代码来源:sfValidatorSchema.class.php


示例15: getArguments

 /**
  * Returns the arguments needed to format the message.
  *
  * @param bool $raw  false to use it as arguments for the message format, true otherwise (default to false)
  *
  * @see getMessageFormat()
  */
 public function getArguments($raw = false)
 {
     if ($raw) {
         return $this->arguments;
     }
     $arguments = array();
     foreach ($this->arguments as $key => $value) {
         if (is_array($value)) {
             continue;
         }
         $arguments["%{$key}%"] = htmlspecialchars($value, ENT_QUOTES, sfValidatorBase::getCharset());
     }
     return $arguments;
 }
开发者ID:HaakonME,项目名称:porticoestate,代码行数:21,代码来源:sfValidatorError.class.php


示例16: configure

 public function configure()
 {
     sfValidatorBase::setDefaultMessage('required', __('GENERAL_REQUIRED_FIELD_ERROR'));
     sfValidatorBase::setDefaultMessage('min_length', sprintf(__('GENERAL_FIELD_TOO_SHORT_ERROR'), '"%value%"', '%min_length%'));
     $this->setWidgets(array('file' => new sfWidgetFormInputFile()));
     $this->widgetSchema->setNameFormat('import[%s]');
     $this->setValidators(array('file' => new sfValidatorFile(array('required' => true))));
     $validMimeTypes = array('application/xml');
     $this->validatorSchema['file']->setOption('mime_types', $validMimeTypes);
     $this->validatorSchema['file']->setOption('max_size', 4000000);
     $messages = array('invalid' => 'Invalid file.', 'max_size' => 'The file can\'t be bigger than 4 MB', 'mime_types' => 'The file must be of XML format.');
     $this->validatorSchema['file']->setMessages($messages);
     $this->widgetSchema->setLabels(array('file' => 'File:'));
     $this->widgetSchema->setNameFormat('import[%s]');
 }
开发者ID:ntemple,项目名称:intelli-plancake,代码行数:15,代码来源:ImportForm.class.php


示例17: __construct

 /**
  * Constructor.
  *
  * The first argument can be:
  *
  *  * null
  *  * a sfValidatorBase instance
  *  * an array of sfValidatorBase instances
  *
  * @param mixed $validators  Initial validators
  * @param array $options     An array of options
  * @param array $messages    An array of error messages
  *
  * @see sfValidatorBase
  */
 public function __construct($validators = null, $options = array(), $messages = array())
 {
     if ($validators instanceof sfValidatorBase) {
         $this->addValidator($validators);
     } else {
         if (is_array($validators)) {
             foreach ($validators as $validator) {
                 $this->addValidator($validator);
             }
         } else {
             if (null !== $validators) {
                 throw new InvalidArgumentException('sfValidatorOr constructor takes a sfValidatorBase object, or a sfValidatorBase array.');
             }
         }
     }
     parent::__construct($options, $messages);
 }
开发者ID:cuongnv540,项目名称:jobeet,代码行数:32,代码来源:sfValidatorOr.class.php


示例18: __construct

 /**
  * Constructor.
  *
  * The first argument can be:
  *
  *  * null
  *  * a sfValidatorBase instance
  *  * an array of sfValidatorBase instances
  *
  * @param mixed $validators Initial validators
  * @param array $options    An array of options
  * @param array $messages   An array of error messages
  *
  * @see sfValidatorBase
  */
 public function __construct($validators = null, $options = array(), $messages = array())
 {
     if ($validators instanceof sfValidatorBase) {
         $this->addValidator($validators);
     } else {
         if (is_array($validators)) {
             foreach ($validators as $validator) {
                 $this->addValidator($validator);
             }
         } else {
             if (!is_null($validators)) {
                 throw new InvalidArgumentException('sfValidatorAnd constructor takes a sfValidatorBase object, or a sfValidatorBase array.');
             }
         }
     }
     if (!isset($options['required'])) {
         $options['required'] = false;
     }
     parent::__construct($options, $messages);
 }
开发者ID:WIZARDISHUNGRY,项目名称:symfony,代码行数:35,代码来源:sfValidatorAnd.class.php


示例19: askAndValidate

 /**
  * Asks for a value and validates the response.
  *
  * Available options:
  *
  *  * value:    A value to try against the validator before asking the user
  *  * attempts: Max number of times to ask before giving up (false by default, which means infinite)
  *  * style:    Style for question output (QUESTION by default)
  *
  * @param   string|array    $question
  * @param   sfValidatorBase $validator
  * @param   array           $options
  *
  * @return  mixed
  */
 public function askAndValidate($question, sfValidatorBase $validator, array $options = array())
 {
     if (!is_array($question)) {
         $question = array($question);
     }
     $options = array_merge(array('value' => null, 'attempts' => false, 'style' => 'QUESTION'), $options);
     // does the provided value passes the validator?
     if ($options['value']) {
         try {
             return $validator->clean($options['value']);
         } catch (sfValidatorError $error) {
         }
     }
     // no, ask the user for a valid user
     $error = null;
     while (false === $options['attempts'] || $options['attempts']--) {
         if (null !== $error) {
             $this->logBlock($error->getMessage(), 'ERROR');
         }
         $value = $this->ask($question, $options['style'], null);
         try {
             return $validator->clean($value);
         } catch (sfValidatorError $error) {
         }
     }
     throw $error;
 }
开发者ID:yuxw75,项目名称:Surrogate,代码行数:42,代码来源:sfTask.class.php


示例20: isEmpty

 /**
  * @see sfValidatorBase
  */
 protected function isEmpty($value)
 {
     if (is_array($value)) {
         // array is not empty when a value is found
         foreach ($value as $key => $val) {
             // int and string '0' are 'empty' values that are explicitly accepted
             if ($val === 0 || $val === '0' || !empty($val)) {
                 return false;
             }
         }
         return true;
     }
     return parent::isEmpty($value);
 }
开发者ID:HaakonME,项目名称:porticoestate,代码行数:17,代码来源:sfValidatorTime.class.php



注:本文中的sfValidatorBase类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP sfWebRequest类代码示例发布时间:2022-05-23
下一篇:
PHP sfValidator类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap