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


PHP Validation::check方法代码示例

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


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

示例1: validate

 /**
  * Default validation field
  * if validation failed method 
  * throw validation exception
  */
 public function validate($value)
 {
     $this->validation = new Validation(array($this->get_name() => $value));
     //$this->validation->label($this->get_name(), $this->get_name());
     if ($this->item['notnull']) {
         if ($value == null) {
             $this->validation->rule($this->get_name(), 'not_empty');
         }
     }
     if (!$this->validation->check()) {
         throw new Validation_Exception($this->validation);
     }
     return $this->validation;
 }
开发者ID:raku,项目名称:MorCMS,代码行数:19,代码来源:execute.php

示例2: action_show

 public function action_show()
 {
     $arr = [];
     //Получаем данные из формы
     if (isset($_POST['submit'])) {
         //Проверяем введенные данные на корректность
         $post = new Validation($_POST);
         $post->rule('prime', 'not_empty')->rule('prime', 'numeric');
         if ($post->check()) {
             $max = $_POST['prime'];
             $arr = Controller_PrimeNumber::getPrime($max);
             Controller_DataArchive::saveDB($max, $arr);
         } else {
             $errors = $post->errors('comments');
         }
     }
     //Подготавливаем данные для вида
     $view = View::factory('index');
     if (isset($errors)) {
         $view->err = $errors;
     } else {
         if (!empty($arr)) {
             $view->arr = $arr;
         }
     }
     $this->response->body($view);
 }
开发者ID:safronovdanil,项目名称:SiteActive,代码行数:27,代码来源:PrimeNumber.php

示例3: validate

 public function validate(CM_Form_Abstract $form)
 {
     $values = array();
     foreach ($form->get_values() as $name => $value) {
         $values[$name] = $value->get_raw();
         $this->_validation->label($name, $form->get_field($name)->get_label());
     }
     // Validation только read-only, поэтому создаем новый объект
     $this->_validation = $this->_validation->copy($values);
     if ($this->_validation->check()) {
         return TRUE;
     }
     foreach ($this->_validation->errors('validation') as $name => $error) {
         $form->set_error($name, $error);
     }
     return FALSE;
 }
开发者ID:ariol,项目名称:adminshop,代码行数:17,代码来源:Validate.php

示例4: submit

 public function submit()
 {
     list($this->validationFlag, $this->validation) = Validation::check(array('nombre' => 'required'));
     if ($this->validationFlag) {
         $nombre = Request::getPost('nombre');
         Db::insert('empresas', array('nombre' => $nombre, 'fecha_creacion' => time()));
         Response::setRedirect('/personas');
     }
 }
开发者ID:joksnet,项目名称:php-old,代码行数:9,代码来源:EmpresasAgregar.php

示例5: check

 /**
  * @param bool $throwException
  *
  * @throws RestfulAPI_Exception_422
  * @return bool
  */
 public function check($throwException = TRUE)
 {
     $result = parent::check();
     if (!$result && $throwException) {
         //			var_dump($this->data(), $this->getRules());
         //			die();
         throw new RestfulAPI_Exception_422($this->errors());
     }
     return $result;
 }
开发者ID:vspvt,项目名称:kohana-restfulapi,代码行数:16,代码来源:Validation.php

示例6: submit

 public function submit()
 {
     list($this->validationFlag, $this->validation) = Validation::check(array('nombre' => 'required', 'apellido' => 'required'));
     if ($this->validationFlag) {
         $nombre = Request::getPost('nombre');
         $apellido = Request::getPost('apellido');
         $correo = Request::getPost('correo');
         $cargo = Request::getPost('cargo');
         Db::insert('personas', array('id_empresas' => $this->idEmpresas, 'nombre' => $nombre, 'apellido' => $apellido, 'correo' => $correo, 'cargo' => $cargo, 'fecha_creacion' => time()));
         Response::setRedirect("/empresas/{$this->idEmpresas}/personas");
     }
 }
开发者ID:joksnet,项目名称:php-old,代码行数:12,代码来源:EmpresasPersonasAgregar.php

示例7: _login

 protected function _login(Validation $validation, $remember)
 {
     if ($validation->check()) {
         Observer::notify('login_before', $validation);
         if (Auth::instance()->login($validation[$this->get('login_field')], $validation[$this->get('password_field')], $remember)) {
             Observer::notify('login_success', $validation[$this->get('login_field')]);
             HTTP::redirect($this->get_next_url());
         } else {
             Observer::notify('login_failed', $validation);
             Messages::errors(__('Login failed. Please check your login data and try again.'));
         }
     }
     HTTP::redirect(Request::current()->referrer());
 }
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:14,代码来源:login.php

示例8: action_index

 public function action_index()
 {
     $installation_status = Kohana::$config->load('install.status');
     switch ($installation_status) {
         case NOT_INSTALLED:
             if (!$this->check_installation_parameters()) {
                 //$data['title']=__('Installation: something wrong');
                 // $this->data=Arr::merge($this->data, Helper::get_db_settings());
                 $this->data = Arr::merge($this->data, get_object_vars($this->install_config));
                 $res = View::factory('install_form', $this->data)->render();
                 //Model::factory('model_name')->model_method( $data );
             } else {
                 $_post = Arr::map('trim', $_POST);
                 $post = new Validation($_post);
                 $post->rule('db_path', 'not_empty')->rule('db_name', 'not_empty')->rule('db_login', 'not_empty')->rule('installer_login', 'not_empty')->rule('installer_password', 'not_empty');
                 if ($post->check()) {
                     Helper::save_install_settings($post);
                     if (!Model::factory('install')->install($err_list)) {
                         Helper::set_installation_status(NOT_INSTALLED);
                         foreach ($err_list as $e) {
                             $this->data['errors'][] = $e['error'];
                         }
                         $res = View::factory('installing', $this->data)->render();
                     } else {
                         $res = View::factory('installing_ok', $this->data)->render();
                     }
                 } else {
                     // Кажется что-то случилось
                     //$data['title']=__('Installation: something wrong');
                     $this->data['errors'] = $post->errors('validation');
                     $res = View::factory('install_form', $this->data)->render();
                 }
             }
             break;
         case INSTALLING:
             $res = View::factory('installing')->render();
             break;
         case INSTALLED:
             //                    $res = View::factory('/')->render();
             $this->redirect('/');
             break;
         default:
             //                    $res = View::factory('/')->render();
             $this->redirect('/');
             break;
     }
     // Save result / Сохраняем результат
     $this->_result = $res;
 }
开发者ID:g-a-g,项目名称:its2015,代码行数:49,代码来源:install.php

示例9: validate

 public function validate($data)
 {
     $val = new Validation($data);
     foreach ($this->validator as $key => $rules) {
         foreach ($rules as $rule => $value) {
             if (is_numeric($rule)) {
                 $val->rule($key, $value);
             } else {
                 $val->rule($key, $rule, $value);
             }
         }
     }
     $val->check();
     return $val->errors();
 }
开发者ID:Alex-AG,项目名称:exeltek-po,代码行数:15,代码来源:Form.php

示例10: submit

 public function submit()
 {
     $this->usuario = Request::getPost('usuario');
     $this->contrasena = md5(Request::getPost('contrasena'));
     $this->recordar = Request::getPost('recordar', 0);
     list($this->validationFlag, $this->validation) = Validation::check(array('usuario' => 'required', 'contrasena' => 'required'));
     if ($this->validationFlag) {
         $idPersonas = Db::one("SELECT personas.id_personas\n                   FROM personas\n                  WHERE personas.usuario = '{$this->usuario}'\n                    AND personas.contrasena = '{$this->contrasena}'\n                  LIMIT 1");
         if ($idPersonas) {
             Session::unregister();
             Session::register($this->usuario, $this->contrasena, $this->recordar == 1);
             Response::setRedirect('/');
         }
         $this->validationFlag = false;
     }
 }
开发者ID:joksnet,项目名称:php-old,代码行数:16,代码来源:Ingresar.php

示例11: index

 public function index()
 {
     //add params
     $user = new User();
     if ($user->isLoggedIn()) {
         Redirect::to('account');
         //$this->view('user/index', ['flash' => '', 'name' => $user->data()->name]);
     } else {
         if (Input::exists()) {
             if (Token::check(Input::get('token'))) {
                 $validate = new Validation();
                 $validation = $validate->check($_POST, array('username' => array('required' => true), 'password' => array('required' => true)));
                 if ($validation->passed()) {
                     $user = new User();
                     $remember = Input::get('remember') === 'on' ? true : false;
                     $login = $user->login(Input::get('username'), Input::get('password'), $remember);
                     if ($login) {
                         //login success
                         Session::flash('account', 'You are now logged in');
                         Redirect::to('account');
                     } else {
                         //login failed
                         $error_string = 'Username or passowrd incorrect<br>';
                         $this->view('login/failed', ['loggedIn' => 2, 'page_heading' => 'Login', 'errors' => $error_string]);
                     }
                 } else {
                     $error_string = '';
                     //there were errors
                     //Create a file that prints errors
                     foreach ($validation->errors() as $error) {
                         $error_string .= $error . '<br>';
                     }
                     $this->view('login/failed', ['loggedIn' => 0, 'page_name' => 'Login', 'errors' => $error_string]);
                 }
             } else {
                 //token did not match so go back to login page
                 $this->view('login/index', ['loggedIn' => 2, 'page_name' => 'Login']);
             }
         } else {
             $this->view('login/index', ['loggedIn' => 2, 'page_name' => 'Login']);
         }
     }
 }
开发者ID:armourjami,项目名称:armourtake,代码行数:43,代码来源:login.php

示例12: submit

 public function submit()
 {
     if (Request::hasPost('guardar')) {
         list($this->validationFlag, $this->validation) = Validation::check(array('nombre' => 'required', 'apellido' => 'required'));
         if ($this->validationFlag) {
             $nombre = Request::getPost('nombre');
             $apellido = Request::getPost('apellido');
             $correo = Request::getPost('correo');
             $cargo = Request::getPost('cargo');
             $telOficina = Request::getPost('tel_oficina');
             $telOficinaInt = Request::getPost('tel_oficina_int');
             $telCelular = Request::getPost('tel_celular');
             $telFax = Request::getPost('tel_fax');
             $telCasa = Request::getPost('tel_casa');
             Db::update('personas', array('nombre' => $nombre, 'apellido' => $apellido, 'correo' => $correo, 'cargo' => $cargo, 'tel_oficina' => $telOficina, 'tel_oficina_int' => $telOficinaInt, 'tel_celular' => $telCelular, 'tel_fax' => $telFax, 'tel_casa' => $telCasa, 'fecha_modificacion' => time()), "id_personas = '{$this->idPersonas}'");
             Response::setRedirect("/personas/{$this->idPersonas}");
         }
     }
 }
开发者ID:joksnet,项目名称:php-old,代码行数:19,代码来源:PersonasEditar.php

示例13: submit

 public function submit()
 {
     if (Request::hasPost('guardar')) {
         list($this->validationFlag, $this->validation) = Validation::check(array('nombre' => 'required'));
         if ($this->validationFlag) {
             $nombre = Request::getPost('nombre');
             $direccion1 = Request::getPost('direccion_1');
             $direccion2 = Request::getPost('direccion_2');
             $ciudad = Request::getPost('ciudad');
             $estado = Request::getPost('estado');
             $codPostal = Request::getPost('cod_postal');
             $idPaises = Request::getPost('id_paises');
             $web = Request::getPost('web');
             $telOficina = Request::getPost('tel_oficina');
             $telFax = Request::getPost('tel_fax');
             Db::update('empresas', array('nombre' => $nombre, 'direccion_1' => $direccion1, 'direccion_2' => $direccion2, 'ciudad' => $ciudad, 'estado' => $estado, 'cod_postal' => $codPostal, 'id_paises' => $idPaises, 'web' => $web, 'tel_oficina' => $telOficina, 'tel_fax' => $telFax, 'fecha_modificacion' => time()), "id_empresas = '{$this->idEmpresas}'");
             Response::setRedirect("/empresas/{$this->idEmpresas}");
         }
     }
 }
开发者ID:joksnet,项目名称:php-old,代码行数:20,代码来源:EmpresasEditar.php

示例14: action_upload

 public function action_upload()
 {
     $md5 = md5($_FILES['image']['tmp_name']);
     $file = $md5 . '_' . time() . '.' . pathinfo($_FILES['image']['name'])['extension'];
     $fileValidation = new Validation($_FILES);
     $fileValidation->rule('image', 'upload::valid');
     $fileValidation->rule('image', 'upload::type', array(':value', array('jpg', 'png')));
     if ($fileValidation->check()) {
         if ($path = Upload::save($_FILES['image'], $file, DIR_IMAGE)) {
             ORM::factory('File')->set('sid', $this->siteId)->set('name', $_FILES['image']['name'])->set('path', $file)->set('md5', $md5)->set('types', Model_File::FILE_TYPES_IMG)->set('created', time())->set('updated', time())->save();
             $site = ORM::factory('Site')->where('id', '=', $this->siteId)->where('uid', '=', $this->user['id'])->find();
             $site->set('logo', $file)->set('updated', time())->save();
             jsonReturn(1001, '上传成功!', '/media/image/data/' . $file);
         } else {
             jsonReturn(4444, '图片保存失败');
         }
     } else {
         jsonReturn(4444, '图片上传失败');
     }
 }
开发者ID:wangyandong,项目名称:SimpleSite,代码行数:20,代码来源:Site.php

示例15: registration

 public static function registration($formAttribues)
 {
     unset($_SESSION['errors']);
     $email = $formAttribues['email'];
     $password = $formAttribues['password'];
     $name = $formAttribues['name'];
     $password_compare = $formAttribues['password_compare'];
     $username = $formAttribues['username'];
     $attributes = ['name' => $name, 'email' => $email, 'password' => $password, 'password_compare' => $password_compare, 'username' => $username];
     $rules = [[['email', 'password', 'name', 'password_compare', 'username'], 'required'], [['name'], 'type', 'type' => 'string', 'min' => 6, 'max' => 32], [['email'], 'email'], [['password'], 'type', 'type' => 'string', 'min' => 4, 'max' => 32], [['password_compare'], 'compare', 'attribute' => 'password', 'message' => 'Повтор пароля повинен співпадати з паролем'], [['email', 'username'], 'unique', 'tableName' => 'users']];
     $validation = new Validation();
     $validation->check($attributes, $rules);
     if (empty($validation->errors)) {
         $row = Db::insert('users', ['email' => $email, 'password' => md5($password), 'name' => $name, 'username' => $username]);
         setFlash('sucess', 'Бла бла бла ...');
         return true;
     }
     $_SESSION['errors'] = $validation->errors;
     return false;
 }
开发者ID:slavko89,项目名称:newsite,代码行数:20,代码来源:User.php


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