国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Can laravel Validator only validate the data submitted by the form? Can you provide a set of data for verification?
某草草
某草草 2017-05-16 16:48:34
0
2
750

Can I use Validator to verify a given set of data?

public function store(PincardRequest $request){
        這個是方法
}

The following is verification

<?php

namespace App\Http\Requests;

use App\Http\Requests\Request;

class PincardRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'yd'=>array('required','regex:/\p{Han}/u'),

        ];
    }

    public function messages(){
        return [
            'yd.required'=>'不能為空!',

        ];
    }


}

How do I pass yd to the store for verification

某草草
某草草

reply all(2)
劉奇

Thank you, you can do this. Add the following two methods in the controller. If you need to pass array verification, use the following methods

/**
 * Validate the given parameters with the given rules.
 *
 * @param  array  $parameters
 * @param  array  $rules
 * @param  array  $messages
 * @param  array  $customAttributes
 * @return void
 */
public function validateParameters($parameters, array $rules, array $messages = [], array $customAttributes = [])
{
    $validator = $this->getValidationFactory()->make($parameters, $rules, $messages, $customAttributes);

    if ($validator->fails()) {
         $this->throwValidationException(app('request'), $validator);
    }
}

/**
 * 拋出一個驗證異常
 *
 * @param WrapedValidationException $e
 * @param Request                   $request
 *
 * @throws ValidationException
 */
protected function throwWrapedValidationException(WrapedValidationException $e, Request $request)
{
    throw new ValidationException(null, $this->buildFailedValidationResponse($request, $e->getErrors()));
}
Peter_Zhu

That one. . . What does array submission mean? ? ?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template