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


PHP validator類代碼示例

本文整理匯總了PHP中validator的典型用法代碼示例。如果您正苦於以下問題:PHP validator類的具體用法?PHP validator怎麽用?PHP validator使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: validate

 public function validate($file = '', $rule = '', $encode = 'utf8', $VAL = null)
 {
     q4mController::useHelper('validator');
     if ($file == '') {
         $file = str_replace('Model', '', get_class($this)) . 'Rules.php';
     }
     if ($rule == '') {
         $rule = str_replace('Model', '', get_class($this));
     }
     if (file_exists(_SYS_DIR_ . _SETTINGS_DIR_ . $file . 'Rules.php')) {
         include_once _SETTINGS_DIR_ . $file . 'Rules.php';
         if (!isset(${$rule}) || !count(${$rule})) {
             q4mSystem::haltOnError('The requested rule "' . ${$rule} . '" is empty in ', _SYS_DIR_ . _SETTINGS_DIR_ . $file . 'Rules.php', __FILE__, __LINE__);
             exit;
         }
     } else {
         q4mSystem::haltOnError('The file is not found', _SYS_DIR_ . _SETTINGS_DIR_ . $file . 'Rules.php', __FILE__, __LINE__);
         exit;
     }
     $rules = ${$rule};
     $vc = new validator($rules, $encode, $VAL);
     if (count($vc->RULES)) {
         foreach ($vc->RULES as $key => $SV) {
             $vc->validate($key);
         }
     }
     if (count($vc->ERRORS)) {
         return $vc->ERRORS;
     } else {
         return false;
     }
 }
開發者ID:spraynakama,項目名稱:q4m_framework,代碼行數:32,代碼來源:class.q4mModel.php

示例2: registerUser

 public static function registerUser()
 {
     $sql = sql::factory();
     $sql->setTable('community_user');
     $sql->getPosts(['username' => 'string', 'password' => 'string', 'email' => 'string']);
     $validator = new validator();
     $email = $sql->getPost('email');
     $username = $sql->getPost('username');
     $password = $sql->getPost('password');
     $validUsername = $validator->costum($username, function () {
         preg_match('/\\w{4,}/', $username, $match);
         return $match[0] == $username;
     });
     if (!$validUsername) {
         return 'Username darf nur aus Buchstaben Zahlen und Unterstrich bestehen und muss mindestens 4 Zeichen lang sein.';
     }
     if ($sql->num('SELECT id FROM ' . sql::table('community_user') . ' WHERE `username`= "' . $sql->escape($username) . '"')) {
         return 'Benutzername schon vorhanden';
     }
     if (!$validator->email($email)) {
         return 'Bitte geben Sie eine E-Mail Adresse an';
     }
     $salt = userLogin::generateSalt();
     $sql->addDatePost('registerdate', 'now');
     $sql->addPost('salt', $salt);
     extension::get('COMMUNITY_USER_REGISTER', $sql);
     $password = userLogin::hash($password, $salt);
     $sql->addPost('password', $password);
     $sql->save();
     //Mail send
     return true;
 }
開發者ID:pasterntt,項目名稱:dynao-CMS,代碼行數:32,代碼來源:community_register.php

示例3: execute

 public function execute()
 {
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         $validator = new validator($this->output);
         if ($validator->execute($this->pattern)) {
             $this->output->add_system_message("Data validation oke.");
         }
     }
     $this->output->record($_POST);
 }
開發者ID:shannara,項目名稱:banshee,代碼行數:10,代碼來源:validation.php

示例4: init

 protected static function init()
 {
     if (!self::$has_init) {
         spl_autoload_register(array('validator', 'autoloader'), FALSE, TRUE);
         self::$has_init = TRUE;
     }
 }
開發者ID:SwayWebStudio,項目名稱:night.com,代碼行數:7,代碼來源:class.validator.php

示例5: validatelogin

 function validatelogin($login = null)
 {
     $this->login = $login;
     $this->min = 6;
     $this->max = 20;
     validator::validator();
 }
開發者ID:BackupTheBerlios,項目名稱:loquacity-svn,代碼行數:7,代碼來源:validatelogin.class.php

示例6: getFails

 /**
  * エラー対象リソースの配列を取得
  * 
  * @return Array
  */
 public function getFails()
 {
     if (!isset($this->validator)) {
         throw new \Exception('validator not found.');
     }
     return $this->validator->failed();
 }
開發者ID:hoshiko-dev,項目名稱:moderate-framework,代碼行數:12,代碼來源:MfBaseValidation.php

示例7: validateblogurl

 function validateblogurl($blogurl = null)
 {
     $this->blogurl = $blogurl;
     $this->min = 6;
     $this->max = 50;
     validator::validator();
 }
開發者ID:BackupTheBerlios,項目名稱:loquacity-svn,代碼行數:7,代碼來源:validateblogurl.class.php

示例8: validatesecretanswer

 function validatesecretanswer($answer = null)
 {
     $this->answer = $answer;
     $this->min = 6;
     $this->max = 60;
     validator::validator();
 }
開發者ID:BackupTheBerlios,項目名稱:loquacity-svn,代碼行數:7,代碼來源:validatesecretanswer.class.php

示例9: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $url = $request->input('url');
     //驗證提交的url
     $target = ['url' => $url];
     $roule = ['url' => 'required|url'];
     $message = ['url' => $url . '不是合法的url', 'required' => '請求輸入url'];
     $validator = validator::make($target, $roule, $message);
     if ($validator->fails()) {
         return redirect('url')->withErrors($validator);
     }
     //檢測在數據庫
     $result = Url::where('url', $url)->first();
     //dd($result);
     if ($result) {
         return view('url.result')->with('short_url', $result->short_url);
     }
     //檢測不在數據庫
     $short_url = Url::get_short_url();
     $res = Url::insert(['url' => $url, 'short_url' => $short_url]);
     if ($res) {
         return view('url.result')->with('short_url', $short_url);
     } else {
         return '數據添加失敗';
     }
 }
開發者ID:jew977,項目名稱:laravel5_unique_short_url-,代碼行數:31,代碼來源:UrlController.php

示例10: validatedbname

 function validatedbname($dbname = null)
 {
     $this->dbname = $dbname;
     $this->min = 6;
     $this->max = 64;
     validator::validator();
 }
開發者ID:BackupTheBerlios,項目名稱:loquacity-svn,代碼行數:7,代碼來源:validatedbname.class.php

示例11: validatedbpasswd

 function validatedbpasswd($dbpasswd = null)
 {
     $this->dbpasswd = $dbpasswd;
     $this->min = 6;
     $this->max = 20;
     validator::validator();
 }
開發者ID:BackupTheBerlios,項目名稱:loquacity-svn,代碼行數:7,代碼來源:validatedbpasswd.class.php

示例12: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $user_id = Auth::User()->id;
     if (Input::file()) {
         $file_image = array('image' => Input::file('file_image'));
         $rules = array('image' => 'required');
         $validator = validator::make($file_image, $rules);
         if ($validator->fails()) {
             return redirect::to('photo')->withInput()->withErrors($validator);
         } else {
             if (Input::file('file_image')->isValid()) {
                 $path = '../public/images';
                 $extension = Input::file('file_image')->getClientOriginalExtension();
                 $fileName = rand() . '.' . $extension;
                 Input::file('file_image')->move($path, $fileName);
                 Image::create(array('user_id' => $user_id, 'path' => $fileName));
                 Session::flash('success', 'Upload successfully');
                 return Redirect::to('photo');
             } else {
                 Session::flash('error', 'uploaded file is not valid');
                 return Redirect::to('photo');
             }
         }
     }
 }
開發者ID:GrigorAtaryan,項目名稱:Social_network,代碼行數:31,代碼來源:ImageController.php

示例13: validateauthorname

 function validateauthorname($aname = null)
 {
     $this->aname = $aname;
     $this->min = 4;
     $this->max = 50;
     validator::validator();
 }
開發者ID:BackupTheBerlios,項目名稱:loquacity-svn,代碼行數:7,代碼來源:validateauthorname.class.php

示例14: validatedbuser

 function validatedbuser($dbuser = null)
 {
     $this->dbuser = $dbuser;
     $this->min = 6;
     $this->max = 16;
     validator::validator();
 }
開發者ID:BackupTheBerlios,項目名稱:loquacity-svn,代碼行數:7,代碼來源:validatedbuser.class.php

示例15: action_index

 function action_index()
 {
     if (isset($_POST['submit'])) {
         $validator = new validator();
         $data["errors"]["login"] = $validator->is_correct_login($_POST['login']) ? "" : "has-error";
         $data["errors"]["pass"] = $validator->is_correct_pass($_POST['password']) ? "" : "has-error";
         if ($this->model->approveUser($_POST['login'], $_POST['password']) && $validator->result) {
             header("Location: /main");
         } else {
             $data["errors"]["login"] = "has-error";
             $data["errors"]["pass"] = "has-error";
         }
     }
     $data["login"] = $this->model->get_login();
     $this->view->generate('login_view.php', 'template_view.php', $data);
 }
開發者ID:Kinqston,項目名稱:MasterClass,代碼行數:16,代碼來源:controller_login.php


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