當前位置: 首頁>>代碼示例>>PHP>>正文


PHP v::alphanum方法代碼示例

本文整理匯總了PHP中v::alphanum方法的典型用法代碼示例。如果您正苦於以下問題:PHP v::alphanum方法的具體用法?PHP v::alphanum怎麽用?PHP v::alphanum使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在v的用法示例。


在下文中一共展示了v::alphanum方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: validate

 public function validate()
 {
     // check for a valid library object
     if (!is_a($this->library, 'Library')) {
         throw new Exception('The library object is invalid');
     }
     // check for all required fields
     foreach (static::$required as $field) {
         if (empty($this->data[$field])) {
             throw new Exception('Missing required field: ' . $field);
         }
     }
     // id validation
     if (!is_string($this->data['id']) or !v::alphanum($this->data['id']) or str::length($this->data['id']) !== 32) {
         throw new Exception('Invalid id');
     }
     // type validation
     if (!is_string($this->data['type']) or !v::between($this->data['type'], 2, 32)) {
         throw new Exception('Invalid type');
     }
     // status validation
     if (!in_array($this->data['status'], static::$statuses)) {
         throw new Exception('Invalid status: ' . $this->data['status']);
     }
     // check for invalid updated timestamp
     if (!is_int($this->data['updated']) or !v::between(date('Y', $this->data['updated']), 1980, 2500)) {
         throw new Exception('Invalid updated timestamp');
     }
     // check for invalid created timestamp
     if (!is_int($this->data['created']) or !v::between(date('Y', $this->data['created']), 1980, 2500) or $this->data['created'] > time()) {
         throw new Exception('Invalid created timestamp');
     }
 }
開發者ID:Zegnat,項目名稱:library,代碼行數:33,代碼來源:item.php

示例2: testAlphaNum

 public function testAlphaNum()
 {
     $this->assertTrue(v::alphanum('abc1234'));
     $this->assertFalse(v::alphanum('#!asdas'));
 }
開發者ID:nsteiner,項目名稱:kdoc,代碼行數:5,代碼來源:VTest.php

示例3: function

 *
 * @return  boolean
 */
v::$validators['requiredWith'] = function ($key, $dependency, $array) {
    return !empty($array[$dependency]) && v::required($key, $array);
};
/**
 * Required (Conditionally)
 *
 * Field has to be present only if the other specified field IS NOT present.
 *
 * @param   string  $key         Name of the field to test.
 * @param   string  $dependency  Name of the field the actual field depends on.
 * @param   array   $array       Collection of data values.
 *
 * @return  boolean
 */
v::$validators['requiredWithout'] = function ($key, $dependency, $array) {
    return !empty($array[$dependency]) || v::required($key, $array);
};
/**
 * Username Validator
 *
 * Ensures the given user name exists in the system.
 *
 * @param mixed  $value  Value to test.
 * @return  boolean
 */
v::$validators['user'] = function ($value) {
    return v::alphanum($value) && kirby()->site()->users()->find($value);
};
開發者ID:buditanrim,項目名稱:kirby-comments,代碼行數:31,代碼來源:validators.php


注:本文中的v::alphanum方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。