当前位置: 首页>>代码示例>>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;未经允许,请勿转载。