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


PHP validator函数代码示例

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


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

示例1: register

 public function register()
 {
     if (is_post()) {
         $this->loadHelper('Validator');
         if (captcha()) {
             $data = ['email' => validate('email', 'email'), 'username' => validate('required', 'username'), 'password' => password_hash(validate('required', 'register_token'), PASSWORD_BCRYPT), 'token' => str_rand(40)];
             if (validator($data)) {
                 if ($this->user->checkExistUser($data['email'])) {
                     $data2 = ['firstname' => validate('required', 'firstname'), 'lastname' => validate('required', 'lastname'), 'nickname' => validate('required', 'nickname'), 'major' => validate('required', 'major')];
                     if (validator($data2)) {
                         $this->user->createUser($data, $data2);
                         $validate = $this->user->validate($data['email'], $_POST['register_token']);
                         if (!empty($validate)) {
                             $_SESSION['auth'] = $validate;
                             $_SESSION['user'] = $this->user->getDetail($validate['id']);
                             cache_forgot('user.members.' . user('major'));
                             cache_forgot('user.get.members.' . user('major'));
                         }
                     }
                 }
             }
         }
     }
     return redirect('');
 }
开发者ID:Jakkarin,项目名称:Anchor-system-for-branch-or-group,代码行数:25,代码来源:AuthController.php

示例2: validate_lead

 protected function validate_lead($data)
 {
     $messages = array('meta.company.required' => 'Company name is required', 'meta.phone.required' => 'Phone number is required', 'meta.mobile.required' => 'Mobile number is required', 'fullname.required' => 'Fullname is required');
     $rules = ['fullname' => 'required', 'meta.company' => 'required', 'meta.phone' => 'required', 'meta.mobile' => 'required'];
     $validator = validator()->make($data, $rules, $messages);
     return $validator;
 }
开发者ID:xhoiyenx,项目名称:referral,代码行数:7,代码来源:User.php

示例3: validate_update

 protected function validate_update($input, $id)
 {
     $rules = ['fullname' => 'required', 'usermail' => 'required|email|unique:members,usermail,' . $id, 'mobile' => 'required|numeric', 'address' => 'required'];
     $messages = array('fullname.required' => 'Fullname is required', 'usermail.required' => 'Email is required', 'usermail.confirmed' => 'Email confirmation does not match.', 'usermail.unique' => 'Email has already been taken.', 'mobile.required' => 'Mobile number is required', 'mobile.numeric' => 'Mobile number needs all numeric', 'address.required' => 'Address is required');
     $validator = validator()->make($input, $rules, $messages);
     return $validator;
 }
开发者ID:xhoiyenx,项目名称:referral,代码行数:7,代码来源:Member.php

示例4: validate

 /**
  * @throws Exception
  */
 protected function validate()
 {
     $validator = validator($this->data, $this->rules);
     if ($validator->fails()) {
         throw new Exception('Invalid data: ' . $validator->getMessageBag()->first());
     }
 }
开发者ID:timmcleod,项目名称:laravel-view-model,代码行数:10,代码来源:BaseViewModel.php

示例5: validate

 protected function validate($data)
 {
     $messages = array('name.required' => 'Name is required', 'price.required' => 'Price is required', 'fee.required' => 'Referral fee is required');
     $rules = ['name' => 'required', 'price' => 'required', 'fee' => 'required'];
     $validator = validator()->make($data, $rules, $messages);
     return $validator;
 }
开发者ID:xhoiyenx,项目名称:referral,代码行数:7,代码来源:Solution.php

示例6: __construct

 public function __construct(GroupRepo $groupRepo)
 {
     parent::__construct();
     validator()->extend('max_depth', function ($name, $groupId) use($groupRepo) {
         //			$groupRepo->getCurrentDepth($groupId);
         //			dd( __LINE__ . ':[' . __FILE__ . ']', $item1, $item2, $item3 );
     });
 }
开发者ID:donny5300,项目名称:translations,代码行数:8,代码来源:StoreGroupRequest.php

示例7: validator

 private function validator($data, $type)
 {
     $rules = config("mailrules.{$type}", 'mailrules.basic');
     $messages = config("mailmessages.{$type}", 'mailmessages.basic');
     if (is_array($data)) {
         return validator($data, $rules, $messages);
     }
     return false;
 }
开发者ID:wdmtech,项目名称:laravel-mail,代码行数:9,代码来源:Mail.php

示例8: validate

 protected function validate($data, $id = null)
 {
     $messages = array('fullname.required' => 'Name is required', 'usermail.required' => 'Email is required', 'usermail.unique' => 'Email has already been taken', 'mobile.required' => 'Mobile number is required', 'mobile.numeric' => 'Mobile number needs all numeric');
     $rules = ['fullname' => 'required', 'usermail' => 'required|email|unique:sales,usermail,' . $id, 'mobile' => 'required|numeric', 'password' => 'required|confirmed'];
     if (!is_null($id)) {
         $rules['password'] = 'sometimes|confirmed';
     }
     $validator = validator()->make($data, $rules, $messages);
     return $validator;
 }
开发者ID:xhoiyenx,项目名称:referral,代码行数:10,代码来源:Sales.php

示例9: validate

 protected function validate($data, $id = null)
 {
     $messages = array('company.required' => 'Company name is required', 'phone.required' => 'Contact number is required', 'phone.numeric' => 'Contact number needs all numeric', 'fullname.required' => 'Fullname is required', 'tnc.accepted' => 'Please check terms and conditions', 'introduce.required' => 'Please fill info on how will you introduce us', 'solutions.required' => 'Please select one or more solutions available', 'company.leadcheck' => 'You just add another lead with the same company name in last 24 hours');
     $rules = ['fullname' => 'required', 'company' => 'required|leadcheck', 'phone' => 'required|numeric', 'usermail' => 'sometimes|email', 'tnc' => 'accepted', 'introduce' => 'required', 'solutions' => 'required'];
     if (!is_null($id)) {
         unset($rules['tnc']);
     }
     $validator = validator()->make($data, $rules, $messages);
     return $validator;
 }
开发者ID:xhoiyenx,项目名称:referral,代码行数:10,代码来源:Lead.php

示例10: index

 public function index()
 {
     $str = request('str');
     $validator = validator(['str' => $str], ['str' => 'required']);
     if ($validator->fails()) {
         $messages = $validator->messages();
         return $messages->first('str');
     }
     //TODO 支持大写输出
     return md5($str);
 }
开发者ID:LuckyHJH,项目名称:tools,代码行数:11,代码来源:Md5Controller.php

示例11: index

 function index()
 {
     //生成二维码图片(直接调用第三方接口 http://www.liantu.com/pingtai/)
     $str = request('str');
     $validator = validator(['str' => $str], ['str' => 'required']);
     if ($validator->fails()) {
         $messages = $validator->messages();
         return $messages->first('str');
     }
     $content = file_get_contents('http://qr.liantu.com/api.php?text=' . $str);
     return response($content)->header('Content-Type', 'image/png');
 }
开发者ID:LuckyHJH,项目名称:tools,代码行数:12,代码来源:QrController.php

示例12: isValid

 public function isValid($userData, $user)
 {
     if ($user->password != null && $userData['password'] == null) {
         unset($this->rules['password']);
         unset($this->rules['password_confirmation']);
     }
     if ($user->email != null && $userData['email'] == $user->email) {
         $this->rules['email'] = 'required|email|min:6';
     }
     $validate = validator($userData, $this->rules);
     return $validate;
 }
开发者ID:haster312,项目名称:laravel_rikkei,代码行数:12,代码来源:User.php

示例13: newItemWith

 public static function newItemWith(array $attributes)
 {
     $validator = validator($attributes, ["article_id" => "required", "article_type" => "required", "name" => "required", "price" => "required|int", "quantity" => "int", "attributes" => "array"]);
     if ($validator->fails()) {
         throw new InvalidCartItemException();
     }
     $item = new static($attributes);
     if (isset($attributes["attributes"])) {
         foreach ($attributes["attributes"] as $attribute => $value) {
             $item->setCustomAttribute($attribute, $value, false);
         }
     }
     return $item;
 }
开发者ID:dvlpp,项目名称:merx,代码行数:14,代码来源:CartItem.php

示例14: __construct

 public function __construct()
 {
     parent::__construct();
     validator()->extend('unique_array', function ($attributes, $values) {
         $array = [];
         foreach ($values as $key => $value) {
             if (in_array($value, $array)) {
                 return false;
             }
             $array[] = $value;
         }
         return true;
     });
 }
开发者ID:donny5300,项目名称:translations,代码行数:14,代码来源:Request.php

示例15: index

 function index()
 {
     $str = request('str');
     $type = request('type');
     $validator = validator(['str' => $str], ['str' => 'required']);
     if ($validator->fails()) {
         $messages = $validator->messages();
         return $messages->first('str');
     }
     if ($type == 'decode') {
         return base64_decode($str);
     } else {
         return base64_encode($str);
     }
 }
开发者ID:LuckyHJH,项目名称:tools,代码行数:15,代码来源:Base64Controller.php


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