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


PHP Validator::make方法代碼示例

本文整理匯總了PHP中Illuminate\Contracts\Validation\Validator::make方法的典型用法代碼示例。如果您正苦於以下問題:PHP Validator::make方法的具體用法?PHP Validator::make怎麽用?PHP Validator::make使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Contracts\Validation\Validator的用法示例。


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

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(PaiementRequest $request)
 {
     $validator = Validator::make($request->all(), ['type_carte' => 'required|alpha', 'numero_carte' => 'required|size:16|alpha_num', 'cryptogramme' => 'required|max:255|alpha_num']);
     if ($validator->fails()) {
         return redirect('post/create')->withErros($validator)->withInput();
     }
 }
開發者ID:AdrienLeveque,項目名稱:Room_Project,代碼行數:13,代碼來源:Client_reservation_paiementController.php

示例2: create

 /**
  * Create a new user
  *
  * https://laravel.com/docs/5.1/validation
  * @param  array $data
  * @return User
  */
 public static function create(array $attributes = [])
 {
     $table = with(new static())->table;
     //$v = self::validator($data);
     $v = Validator::make($attributes, static::$rules);
     $return = null;
     if ($v->passes()) {
         parent::create($attributes);
         $lastid = \DB::getpdo()->lastinsertid();
         $return = $lastid;
     } else {
         //$messages = $v->errors();
         $return = $v;
     }
     return $table;
 }
開發者ID:odenktools,項目名稱:stoplite,代碼行數:23,代碼來源:User.php

示例3: validator

 /**
  * Get a validator for an incoming registration request.
  *
  * @param  array  $data
  * @return \Illuminate\Contracts\Validation\Validator
  */
 protected function validator(array $data)
 {
     return Validator::make($data, ['name' => 'required|max:255', 'email' => 'required|email|max:255|unique:users', 'password' => 'required|confirmed|min:6']);
 }
開發者ID:sctape,項目名稱:scheduler,代碼行數:10,代碼來源:AuthController.php

示例4: createValidator

 /**
  * @param $value
  * @param $validator
  *
  * @return mixed
  * @throws \Exception
  */
 protected function createValidator($value, $validator)
 {
     $validator = Validator::make(['email' => 'kieran@hello.com', 'username' => 'kdadler'], ['email' => 'required|email|unique:users', 'username' => 'unique:users']);
     return $validator;
 }
開發者ID:kdadler,項目名稱:just_teach,代碼行數:12,代碼來源:Filter.php

示例5: doLogin

 public function doLogin()
 {
     // validate the info, create rules for the inputs
     $rules = array('email' => 'required|email', 'password' => 'required|alphaNum|min:6');
     // run the validation rules on the inputs from the form
     $validator = Validator::make(Input::all(), $rules);
     // if the validator fails, redirect back to the form
     if ($validator->fails()) {
         return Redirect::to('/')->withErrors($validator)->withInput(Input::except('password'));
         // send back the input (not the password) so that we can repopulate the form
     } else {
         // create our user data for the authentication
         $userdata = array('email' => Input::get('email'), 'password' => Input::get('password'));
         // attempt to do the login
         if (Auth::attempt($userdata)) {
             // validation successful!
             // redirect them to the secure section or whatever
             // return Redirect::to('secure');
             // for now we'll just echo success (even though echoing in a controller is bad)
             echo 'SUCCESS!';
         } else {
             // validation not successful, send back to form
             return Redirect::to('/');
         }
     }
 }
開發者ID:sandrovw64,項目名稱:comanda-teste,代碼行數:26,代碼來源:HomeController.php


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