本文整理汇总了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();
}
}
示例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;
}
示例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']);
}
示例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;
}
示例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('/');
}
}
}