Laravel 的Validation验证规则,required_if、required_without等表示的意思

验证规则实例:

public function demo(Request $request) 
{
    $this->validate([
        'name' => 'required',
        'type' => 'required|in:1,2,3',
 
        //当type=1的时候words必传
        'words' => 'required_if:type,1|between:10,5000',
 
        //experitime和experimonth只能二选一,并且experitime只能是大于明天的时间
        'experitime' => 'date|after:tomorrow|required_without:experimonth',
        'experimonth' => 'int|required_without:experitime',
     ]);
}
 

更多验证规则:
英文文档:https://laravel.com/docs/5.1/validation#rule-mimes

中文文档:https://learnku.com/docs/laravel/5.5/validation/1302#available-validation-rules

你可能感兴趣的:(laravel,php,laravel)