Laravel 4: Validate start and end date with before and after validation

后端 未结 5 1609
深忆病人
深忆病人 2021-01-27 07:22

I want to validate two date fields in a form which is from_date and end_date. Need to check from_date is less than end_date.

$rules = array(\'from_date\' => a         


        
5条回答
  •  星月不相逢
    2021-01-27 07:50

    I know that it is a question about Laravel 4 BUT if you are using Laravel 5.3 now you can use something like:

    $rules = array(
    
       'date_start' => 'required|date_format:Y-m-d|before_or_equal:date_end',
       'date_end' => 'required|date_format:Y-m-d|after_or_equal:date_start'
    
           );
    
        $validator = Validator::make($request->all(), $rules);
    

提交回复
热议问题