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


PHP Validate类代码示例

本文整理汇总了PHP中Validate的典型用法代码示例。如果您正苦于以下问题:PHP Validate类的具体用法?PHP Validate怎么用?PHP Validate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: get_validation

 /**
  * Get validation result (list of parameter keys with boolean values)
  *
  * @param object $candidate  Object to test
  * @return array
  *
  * @access public
  */
 public function get_validation($candidate)
 {
     $v = new Validate();
     $options = $this->get_valid_options();
     $ret = $v->multiple($candidate, $options);
     return $ret;
 }
开发者ID:WillSwales,项目名称:financial-maths-mediawiki,代码行数:15,代码来源:class-ct1-object.php

示例2: changeEmail

    function changeEmail()
    {
        $validator = new Validate();
        $validated = $validator->validateNewEmail();
        $user = \Auth::user();
        $email = $user->email;
        if ($validated->fails()) {
            return \View::make('accounts.email')->withErrors($validated)->withEmail($email);
        }
        if (\Auth::check()) {
            $id = \Auth::user()->user_id;
            \DB::beginTransaction();
            try {
                $statement = \User::find($id);
                $statement->email = \Input::get('email');
                $statement->save();
            } catch (ValidationException $e) {
                DB::rollback();
                throw $e;
            }
            \DB::commit();
            return \Redirect::to('admin/account/edit/email')->with('message', '<p class="alert alert-dismissible alert-success alert-link">Email address updated.	
				</p>')->withEmail($email);
        }
        return \Redirect::to('admin/account/edit/email')->with('message', '<p class="alert alert-dismissible alert-success alert-link">Email address updated.
				</p>')->withEmail($email);
    }
开发者ID:adamyWA,项目名称:Menu-CMS,代码行数:27,代码来源:ChangeEmail.php

示例3: detailAction

 /**
  * 修改专题分类
  */
 public function detailAction($art_ban_id)
 {
     //判断是否是ajax
     if ($this->request->isAjax()) {
         $validate = new \Validate();
         $data['top_cat_id'] = $validate->getPost('top_cat_id', ['int']);
         //专题id
         $data['top_cat_name'] = $validate->getPost('top_cat_name', ['length' => ['max' => 30, 'min' => 0]], ['slashes' => true, 'html' => true]);
         //专题分类名称
         //验证参数
         if ($validate->getMessage()) {
             $this->end(400);
         }
         //修改专题
         $result = (new \TopicCategory())->updTopicCategory($this->session->get('id'), $data);
         $this->end($result);
     }
     //数据id
     $art_ban_id = (int) $art_ban_id;
     //专题分类详情
     $basic = (new \Topic())->getDetail($art_ban_id);
     //加载js
     $this->assets->addJs('backend/mt-js/topiccat.js');
     $this->view->setVars(['basic' => $basic]);
 }
开发者ID:xw716825,项目名称:git_back,代码行数:28,代码来源:TopiccatController.php

示例4: email_tpl_editOp

 /**
  * 编辑邮件模板
  */
 public function email_tpl_editOp()
 {
     $model_templates = Model('mail_templates');
     if (chksubmit()) {
         $obj_validate = new Validate();
         $obj_validate->validateparam = array(array("input" => $_POST["code"], "require" => "true", "message" => L('mailtemplates_edit_no_null')), array("input" => $_POST["title"], "require" => "true", "message" => L('mailtemplates_edit_title_null')), array("input" => $_POST["content"], "require" => "true", "message" => L('mailtemplates_edit_content_null')));
         $error = $obj_validate->validate();
         if ($error != '') {
             showMessage($error);
         } else {
             $update_array = array();
             $update_array['code'] = $_POST["code"];
             $update_array['title'] = $_POST["title"];
             $update_array['content'] = $_POST["content"];
             $result = $model_templates->editTpl($update_array, array('code' => $_POST['code']));
             if ($result === true) {
                 $this->log(L('nc_edit,email_tpl'), 1);
                 showMessage(L('mailtemplates_edit_succ'), 'index.php?act=message&op=email_tpl');
             } else {
                 $this->log(L('nc_edit,email_tpl'), 0);
                 showMessage(L('mailtemplates_edit_fail'));
             }
         }
     }
     if (empty($_GET['code'])) {
         showMessage(L('mailtemplates_edit_code_null'));
     }
     $templates_array = $model_templates->getTplInfo(array('code' => $_GET['code']));
     Tpl::output('templates_array', $templates_array);
     Tpl::output('top_link', $this->sublink($this->links, 'email_tpl'));
     Tpl::showpage('message.email_tpl.edit');
 }
开发者ID:ff00x0,项目名称:shopnc,代码行数:35,代码来源:message.php

示例5: _upload_image

 public function _upload_image(Validate $array, $input)
 {
     if ($array->errors()) {
         // Don't bother uploading
         return;
     }
     // Get the image from the array
     $image = $array[$input];
     if (!Upload::valid($image) or !Upload::not_empty($image)) {
         // No need to do anything right now
         return;
     }
     if (Upload::valid($image) and Upload::type($image, $this->types)) {
         $filename = strtolower(Text::random('alnum', 20)) . '.jpg';
         if ($file = Upload::save($image, NULL, $this->directory)) {
             Image::factory($file)->resize($this->width, $this->height, $this->resize)->save($this->directory . $filename);
             // Update the image filename
             $array[$input] = $filename;
             // Delete the temporary file
             unlink($file);
         } else {
             $array->error('image', 'failed');
         }
     } else {
         $array->error('image', 'valid');
     }
 }
开发者ID:bosoy83,项目名称:progtest,代码行数:27,代码来源:image.php

示例6: save_mallconsultOp

    /**
     * 保存平台咨询
     */
    public function save_mallconsultOp() {
        if (!chksubmit()) {
            showDialog(L('wrong_argument'), 'reload');
        }

        //验证表单信息
        $obj_validate = new Validate();
        $obj_validate->validateparam = array(
            array("input"=>$_POST["type_id"],"require"=>"true","validator"=>"Number","message"=>"请选择咨询类型"),
            array("input"=>$_POST["consult_content"],"require"=>"true","message"=>"请填写咨询内容")
        );
        $error = $obj_validate->validate();
        if ($error != ''){
            showDialog($error);
        }

        $insert = array();
        $insert['mct_id'] = $_POST['type_id'];
        $insert['member_id'] = $_SESSION['member_id'];
        $insert['member_name'] = $_SESSION['member_name'];
        $insert['mc_content'] = $_POST['consult_content'];

        $result = Model('mall_consult')->addMallConsult($insert);
        if ($result) {
            showDialog(L('nc_common_op_succ'), 'reload', 'succ');
        } else {
            showDialog(L('nc_common_op_fail'), 'reload');
        }
    }
开发者ID:noikiy,项目名称:ejia,代码行数:32,代码来源:member_mallconsult.php

示例7: existe

 /**
  * Verifica que la persona exista.
  *
  * Se utiliza para otorgar las constancias.
  *
  * @param Validate $array
  * @param <type> $campo
  */
 public function existe(Validate $array, $campo)
 {
     if (ORM::factory("persona")->where("cedula", "=", $array[$campo])->count_all() == 0) {
         $array->error($campo, "no_existe");
     }
     return $array;
 }
开发者ID:reneegonam,项目名称:CoCo,代码行数:15,代码来源:persona.php

示例8: newAction

 /**
  * 新增属性
  */
 public function newAction()
 {
     //检查是否是ajax请求
     if ($this->request->isAjax()) {
         $validate = new \Validate();
         $data['att_img'] = $validate->getPost('att_img', \Validate::base64());
         //属性图
         $data['att_name'] = $validate->getPost('att_name', \Validate::regex('/^[a-z0-9\\x{4e00}-\\x{9fa5}]{2,30}$/iu'));
         //属性名称
         $data['att_sort'] = $validate->getPost('att_sort', \Validate::int());
         //排序
         //验证数据
         if ($validate->getMessage()) {
             $this->end(400);
         }
         //生成学校logo,缩略图
         $data['att_img'] = \Func::touchImg($data['att_img'], 'att_img');
         //将生成的图片地址存入img,用户失败时删除
         $img = [UPLOAD_PATH . $data['att_img'], UPLOAD_PATH . $data['att_img']];
         //监测图片是否全部生成成功
         if (!$data['att_img']) {
             \FileUtil::getInstance()->unlink($img);
         }
         //新增高校
         $result = (new \Attribute())->addAttribute($this->session->get('id'), $data);
         if ($result != 200) {
             \FileUtil::getInstance()->unlink($img);
         }
         $this->end($result);
     }
     //加载所需js
     $this->assets->addJs('backend/mt-js/attribute-new.js');
 }
开发者ID:xw716825,项目名称:git_back,代码行数:36,代码来源:AttributeController.php

示例9: basicAction

 /**
  * 合作机构基本信息
  */
 public function basicAction($uni_id)
 {
     //判断是否是ajax
     if ($this->request->isAjax()) {
         $validate = new \Validate();
         $data['union_logo'] = $validate->getPost('union_logo');
         //机构logo
         $data['union_name'] = $validate->getPost('union_name', \Validate::regex('/^[a-z0-9\\x{4e00}-\\x{9fa5}]{2,30}$/iu'));
         //机构名称
         //验证参数
         if ($validate->getMessage()) {
             $this->end(400);
         }
         //生成机构logo,缩略图
         if ($data['union_logo']) {
             $data['union_logo'] = \Func::touchImg($data['union_logo'], 'union_logo');
             //监测图片是否生成成功
             if (!$data['union_logo']) {
                 \FileUtil::getInstance()->unlink(UPLOAD_PATH . $data['union_logo']);
                 $this->end(400);
             }
         }
         $this->end((new \Union())->updUnionBasic($this->session->get('id'), $uni_id, $data));
     }
     //机构id
     $uni_id = (int) $uni_id;
     //获取基本数据
     $basic = (new \Union())->getUnionBasic($uni_id);
     //加载js
     $this->assets->addJs('backend/mt-js/union.js');
     $this->view->setVars(['uni_id' => $uni_id, 'basic' => $basic]);
 }
开发者ID:xw716825,项目名称:git_back,代码行数:35,代码来源:UnionController.php

示例10: testOutOfExistsFieldNotFound

 public function testOutOfExistsFieldNotFound()
 {
     $testdata = ["name" => "Foo Bar", "mobile" => "0912345678", "address" => "Hong Kong", "phone" => "12345678"];
     $chk = new Validate($testdata);
     $chk->outOf(["address", "phone", "mobile", "business"], 4);
     $this->assertFalse($chk->validate());
 }
开发者ID:hax4,项目名称:foundation,代码行数:7,代码来源:ValidateTest.php

示例11: newCategory

 public function newCategory()
 {
     $validate = new Validate();
     $validated = $validate->Validate_Category();
     $nameToSlug = $this->nameToSlug($validated);
     if (\Auth::check()) {
         if ($validated->passes() && $nameToSlug === true) {
             $slug = \Input::get('name');
             $slug = preg_replace('#[ -]+#', '-', $slug);
             $slug = strtolower($slug);
             \DB::beginTransaction();
             try {
                 $item = new \MenuCategory();
                 $item->menu_category_name = \Input::get('name');
                 $item->menu_category_slug = $slug;
                 $item->save();
             } catch (ValidationException $e) {
                 DB::rollback();
                 throw $e;
             }
             \DB::commit();
             return \Redirect::to('admin/category/edit/' . $slug)->with('message', '<div class="alert alert-dismissible alert-success alert-link"><button type="button" class="close" data-dismiss="alert">×</button>Saved!</p></div>');
         }
         if ($nameToSlug === false) {
             return \View::make('categories.new')->withErrors($validated)->withInput(array('name'))->with('message', '<p class="alert alert-dismissible alert-danger alert-link">That category already exists!');
         }
         return \View::make('categories.new')->withErrors($validated)->withInput(array('name'));
     }
     return \Redirect::to('admin');
 }
开发者ID:adamyWA,项目名称:Menu-CMS,代码行数:30,代码来源:AddCategory.php

示例12: admin_editOp

 /**
  * 管理员编辑
  */
 public function admin_editOp()
 {
     /**
      * 保存
      */
     if (isset($_POST) && !empty($_POST)) {
         //表单验证
         $obj_validate = new Validate();
         $obj_validate->validateparam = array(array("input" => trim($_POST['admin_password']), "require" => "true", "message" => Language::get('nc_admin_admin_password_is_not_null')), array("input" => trim($_POST['admin_confirm_password']), "require" => "true", "message" => Language::get('nc_admin_password_confirm_is_not_null')));
         $error = $obj_validate->validate();
         if ($error != '') {
             $this->showTip(Language::get('error') . $error, '', 'error');
         }
         $condition = array();
         $condition['admin_id'] = intval($_POST['admin_id']);
         $params = array();
         $params['admin_password'] = md5(trim($_POST['admin_password']));
         $model = Model();
         $result = $model->table('admin')->where($condition)->update($params);
         if ($result) {
             $this->showTip(Language::get('nc_admin_edit_account_succ'));
         } else {
             $this->showTip(Language::get('nc_admin_edit_account_fail'));
         }
     }
     $admin_id = intval($_GET['admin_id']);
     $model = Model();
     $admininfo = $model->table('admin')->where(array('admin_id' => $admin_id))->find();
     if (empty($admininfo)) {
         $this->showTip(Language::get('nc_admin_add_account_succ'));
     }
     Tpl::output('admininfo', $admininfo);
     Tpl::showpage('admin.edit');
 }
开发者ID:noikiy,项目名称:shopnc-2,代码行数:37,代码来源:admin.php

示例13: listAction

 /**
  * 新闻Banner列表
  */
 public function listAction()
 {
     if ($this->request->isAjax()) {
         $validate = new \Validate();
         $id = (int) $validate->getPost('id');
         if (!$id) {
             $this->end(400);
         }
         $this->end((new \SingleReward())->UpdateHandle($id));
     }
     //当前页码
     $page_id = (int) $this->request->getQuery('page');
     $page_id = $page_id < 1 ? 1 : $page_id;
     //每页显示条数
     $limit = 20;
     //显示状态
     $status = $this->request->getQuery('status');
     //关键字
     $keyword = preg_replace('/[^\\da-z\\x{4e00}-\\x{9fa5}]/iu', '', mb_substr($this->request->getQuery('keyword'), 0, 10, 'utf-8'));
     //关键字长度小于10,并且只能是字符数字中文
     //所有显示状态
     $statuses = \Setting::getStatus();
     $statuses = ['' => '所有状态'] + $statuses;
     //列表查询
     $list = (new \SingleReward())->getList($page_id, $limit, $status, $keyword);
     $page_html = $this->pageHtml($list['page']);
     //加载js
     $this->assets->addJs('backend/mt-js/single-reward.js');
     $this->view->setVars(['status' => $status, 'keyword' => $keyword, 'statuses' => $statuses, 'list' => $list['list'], 'page_html' => $page_html]);
 }
开发者ID:xw716825,项目名称:git_back,代码行数:33,代码来源:SinglerewController.php

示例14: check_username

 /**
  * Username callback to check if username is valid
  */
 public function check_username(Validate $array, $field)
 {
     $exists = (bool) DB::select(array('COUNT("*")', 'total_count'))->from('users')->where('username', '=', $array[$field])->execute()->get('total_count');
     if (!$exists) {
         $array->error($field, 'not_found', array($array[$field]));
     }
 }
开发者ID:vimofthevine,项目名称:kohana-admin,代码行数:10,代码来源:auth.php

示例15: detailAction

 /**
  * 修改小初高动态
  */
 public function detailAction($sch_dny_id)
 {
     //判断是否ajax
     if ($this->request->isAjax()) {
         $validate = new \Validate();
         $data['sch_id'] = $validate->getPost('sch_id', ['int']);
         //学校id
         $data['sch_dny_id'] = $validate->getPost('sch_dny_id', ['int']);
         //动态id
         $data['sch_dny_title'] = $validate->getPost('sch_dny_title', \Validate::length(60, 1), ['slashes' => true, 'html' => true]);
         //动态标题
         $data['sch_dny_content'] = $validate->getPost('sch_dny_content', \Validate::nil(), ['slashes' => true]);
         //动态内容
         //验证参数
         if ($validate->getMessage()) {
             $this->end(400);
         }
         $this->end((new \Dynamic())->updDynamic($this->session->get('id'), $data));
     }
     //动态id
     $sch_dny_id = (int) $sch_dny_id;
     //小初高学校动态数据
     $dynamic = (new \Dynamic())->getDynamicDetail($sch_dny_id);
     //获取学校类型
     $sch_dny_type = (new \Dynamic())->getDnyType($sch_dny_id);
     if ($sch_dny_type['sch_type'] == 1) {
         $this->view->setLayout("kindergarten");
     } else {
         $this->view->setLayout("school");
     }
     $this->view->setVars(['sch_dny_id' => $sch_dny_id, 'dynamic' => $dynamic, 'sch_id' => $dynamic['sch_id'], 'sch_dny_type' => $sch_dny_type]);
 }
开发者ID:xw716825,项目名称:git_back,代码行数:35,代码来源:DynamicController.php


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