本文整理汇总了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;
}
示例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'));
}
示例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');
}
示例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']);
}
示例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);
}
示例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());
}
示例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']);
}
示例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);
}