当前位置: 首页>>代码示例>>PHP>>正文


PHP Validator::rule方法代码示例

本文整理汇总了PHP中lithium\util\Validator::rule方法的典型用法代码示例。如果您正苦于以下问题:PHP Validator::rule方法的具体用法?PHP Validator::rule怎么用?PHP Validator::rule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lithium\util\Validator的用法示例。


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

示例1: testEmail

 /**
  * Options variations:
  *   1. +pattern -mx (default)
  *   2. +pattern +mx
  *   3. -pattern -mx
  *   4. -pattern +mx
  *
  * `$emails[0]` with any `$options` or without options should be `true`
  * `$emails[1]` with any `$options` or without options should be `false`
  * `$emails[2]` with `$options[1]` should be `true`
  * `$emails[2]` with `$options[1]` should be `true`
  *
  * `$options[1]` works same as Lithium's default email validator implementation
  */
 public function testEmail()
 {
     $emails = array('li3test@djordjekovacevic.com', 'invalid.djordjekovacevic.com', 'looks.valid@djordjekovacevic.c');
     $options = array(array('mx' => true), array('pattern' => false), array('pattern' => false, 'mx' => true));
     $this->assertTrue(Validator::rule('email', $emails[0]));
     $this->assertTrue(Validator::rule('email', $emails[0], 'any', $options[0]));
     $this->assertTrue(Validator::rule('email', $emails[0], 'any', $options[1]));
     $this->assertTrue(Validator::rule('email', $emails[0], 'any', $options[2]));
     $this->assertFalse(Validator::rule('email', $emails[1]));
     $this->assertFalse(Validator::rule('email', $emails[1], 'any', $options[0]));
     $this->assertFalse(Validator::rule('email', $emails[1], 'any', $options[1]));
     $this->assertFalse(Validator::rule('email', $emails[1], 'any', $options[2]));
     $this->assertFalse(Validator::rule('email', $emails[2], 'any'));
     $this->assertTrue(Validator::rule('email', $emails[2], 'any', $options[1]));
 }
开发者ID:djordje,项目名称:li3_validators,代码行数:29,代码来源:OverriddenTest.php

示例2: _assignAccessors

 protected function _assignAccessors($entity)
 {
     $fields = static::_formattedFields($this->_config['fields']);
     $queried = $entity->export()['data'];
     if (0 === count(array_intersect_key($queried, $fields))) {
         return $entity;
     }
     foreach ($fields as $field => $name) {
         if (isset($_FILES[$field]['name'])) {
             // Attempted file upload
             $file = $_FILES[$field]['name'];
             if (Validator::rule('isUploadedFile', $file, 'any', ['field' => $field])) {
                 // Valid file upload
                 $entity->{$field} = new UploadableStorage($field, $name, $entity);
             }
         } else {
             // Read
             $entity->{$field} = new UploadableStorage($field, $name, $entity);
         }
     }
     return $entity;
 }
开发者ID:johnny13,项目名称:li3_uploadable,代码行数:22,代码来源:Uploadable.php

示例3:

			if(Validator::rule('uniqueEmail', $params['data']['email']) === false) {
				$params['data']['email'] = ''; 
			}
			
		} else {
			// If the fields password and password_confirm both exist, then validate the password field too
			if((isset($params['data']['password'])) && (isset($params['data']['password_confirm']))) {
				if(Validator::rule('moreThanFive', $params['data']['password']) === true) {
					$params['data']['password'] = String::hash($params['data']['password']); // will be sha512
				}
			}
			
			// If the new_email field was passed, the user is requesting to update their e-mail, we will set it and send an email to allow them to confirm, once confirmed it will be changed
			if(isset($params['data']['new_email'])) {
				// Unique E-mail validation
				if((Validator::rule('uniqueEmail', $params['data']['new_email']) === false) || (Validator::isEmail($params['data']['new_email']) === false)) {
					// Invalidate
					$params['data']['new_email'] = '';
				} else {
					$params['data']['approval_code'] = Util::unique_string(array('hash' => 'md5'));
					Email::changeUserEmail(array('first_name' => $params['data']['first_name'], 'last_name' => $params['data']['last_name'], 'to' => $params['data']['new_email'], 'approval_code' => $params['data']['approval_code']));
				}
			}
		}
	
	}
	
	//$data = array($params['entity']->file);
	//Asset::save($data);
	
	return $chain->next($self, $params, $chain);
开发者ID:nateabele,项目名称:Minerva-Plugin,代码行数:31,代码来源:User.php


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