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


PHP Validation::uuid方法代码示例

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


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

示例1: validateKey

 /**
  * validates a primary or foreign key depending on the current schema data for this field
  * recognizes uuid (char36) and aiid (int10 unsigned) - not yet mixed (varchar36)
  * more useful than using numeric or notEmpty which are type specific
  * @param array $data
  * @param array $options
  * - allowEmpty
  * 2011-06-21 ms
  */
 function validateKey($data = array(), $options = array())
 {
     $key = array_shift(array_keys($data));
     $value = array_shift($data);
     $schema = $this->schema($key);
     if (!$schema) {
         return true;
     }
     $defaults = array('allowEmpty' => false);
     $options = am($defaults, $options);
     if ($schema['type'] != 'integer') {
         if ($options['allowEmpty'] && $value === '') {
             return true;
         }
         return Validation::uuid($value);
     }
     if ($options['allowEmpty'] && $value === 0) {
         return true;
     }
     return is_numeric($value) && (int) $value == $value && $value > 0;
 }
开发者ID:robksawyer,项目名称:tools,代码行数:30,代码来源:my_model.php

示例2: testUuid

 public function testUuid()
 {
     $this->assertTrue(Validation::uuid('00000000-0000-0000-0000-000000000000'));
     $this->assertTrue(Validation::uuid('550e8400-e29b-11d4-a716-446655440000'));
     $this->assertFalse(Validation::uuid('BRAP-e29b-11d4-a716-446655440000'));
     $this->assertTrue(Validation::uuid('550E8400-e29b-11D4-A716-446655440000'));
     $this->assertFalse(Validation::uuid('550e8400-e29b11d4-a716-446655440000'));
     $this->assertFalse(Validation::uuid('550e8400-e29b-11d4-a716-4466440000'));
     $this->assertFalse(Validation::uuid('550e8400-e29b-11d4-a71-446655440000'));
     $this->assertFalse(Validation::uuid('550e8400-e29b-11d-a716-446655440000'));
     $this->assertFalse(Validation::uuid('550e8400-e29-11d4-a716-446655440000'));
 }
开发者ID:alvaroziqar,项目名称:galei,代码行数:12,代码来源:ValidationTest.php

示例3: testUuidPrimaryKeyInsertion

 /**
  * Test that records can be inserted with UUID primary keys, and
  * that the primary key is not blank
  *
  * @return void
  */
 public function testUuidPrimaryKeyInsertion()
 {
     $this->loadFixtures('Uuid');
     $Model = ClassRegistry::init('Uuid');
     $data = array('title' => 'A UUID should work', 'count' => 10);
     $Model->create($data);
     $this->assertTrue((bool) $Model->save());
     $result = $Model->read();
     $this->assertEquals($data['title'], $result['Uuid']['title']);
     $this->assertTrue(Validation::uuid($result['Uuid']['id']), 'Not a UUID');
 }
开发者ID:saihe,项目名称:reservation,代码行数:17,代码来源:SqliteTest.php

示例4: _validateId

 /**
  * Is the passed ID valid ?
  *
  * By default we assume you want to validate an numeric string
  * like a normal incremental ids from MySQL
  *
  * Change the validateId settings key to "uuid" for UUID check instead
  *
  * @param mixed $id
  * @return boolean
  * @throws BadRequestException If id is invalid
  */
 protected function _validateId($id)
 {
     $type = $this->config('validateId');
     if ($type === null) {
         $type = $this->detectPrimaryKeyFieldType();
     }
     if (!$type) {
         return true;
     } elseif ($type === 'uuid') {
         $valid = Validation::uuid($id);
     } else {
         $valid = is_numeric($id);
     }
     if ($valid) {
         return true;
     }
     $subject = $this->_trigger('invalidId', compact('id'));
     $message = $this->message('invalidId');
     $exceptionClass = $message['class'];
     throw new $exceptionClass($message['text'], $message['code']);
 }
开发者ID:linking-arts,项目名称:furry-goggles,代码行数:33,代码来源:CrudAction.php

示例5: smsCheckPayment

 public function smsCheckPayment($paycode, &$payed)
 {
     if (Validation::uuid($paycode) == true) {
         /* Set payed always to true, Mollie offers no way to verify the payment
          * we need to trust on their callback
          */
         $payed = 'true';
     } else {
         $payed = 'false';
     }
     return array('payed' => $payed);
 }
开发者ID:djbobke,项目名称:cakephp-mollie,代码行数:12,代码来源:MollieComponent.php

示例6: _validateId

 /**
  * Is the passed ID valid ?
  *
  * By default we assume you want to validate an numeric string
  * like a normal incremental ids from MySQL
  *
  * Change the validateId settings key to "uuid" for UUID check instead
  *
  * @param mixed $id
  * @return boolean
  */
 protected function _validateId($id)
 {
     if (isset($this->settings['validateId'])) {
         $type = $this->settings['validateId'];
     } else {
         $type = $this->_detectPrimaryKeyFieldType();
     }
     if (!$type) {
         return true;
     } elseif ($type === 'uuid') {
         $valid = Validation::uuid($id);
     } else {
         $valid = is_numeric($id);
     }
     if ($valid) {
         return true;
     }
     $subject = $this->trigger('invalidId', compact('id'));
     $this->_setFlash('invalid_id.error');
     return $this->_redirect($subject, $this->_controller->referer());
 }
开发者ID:nodesagency,项目名称:Platform-Crud-Plugin,代码行数:32,代码来源:CrudComponent.php

示例7: testSmsFetchPayment

 /**
  * testSmsFetchPayment method
  *
  * @return void
  */
 public function testSmsFetchPayment()
 {
     $ret = $this->Mollie->smsFetchPayment('12345678', 10000, 'nl');
     $this->assertEqual($ret['amount'], 10000);
     $this->assertEqual(Validation::uuid($ret['paycode']), true);
     $url = parse_url($ret['targetUrl']);
     $this->assertEqual($url['host'], 'www.mollie.nl');
     $this->assertEqual($url['scheme'], 'http');
     $this->assertEqual($url['path'], '/partners/betaal/');
     $query = null;
     parse_str($url['query'], $query);
     $this->assertEqual($query['partnerid'], $this->settings['partnerId']);
     $this->assertEqual($query['id'], '12345678');
     $this->assertEqual($query['land'], 'nl');
     $this->assertEqual($query['parameter'][1], $ret['paycode']);
 }
开发者ID:djbobke,项目名称:cakephp-mollie,代码行数:21,代码来源:MollieComponentTest.php

示例8: assertId

 /**
  *
  *
  * @param integer|string $check
  * @param string $type
  * @return void
  */
 public function assertId($check, $type = 'uuid')
 {
     switch ($type) {
         case 'numeric':
             $check = Validation::numeric($check);
             break;
         default:
             $check = Validation::uuid($check);
             $type = strtoupper($type);
     }
     if (!$check) {
         parent::fail("Failed asserting that '{$check}' is a valid {$type} primary key.");
     }
     $this->addToAssertionCount(1);
 }
开发者ID:gourmet,项目名称:common,代码行数:22,代码来源:CommonTestCase.php


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