Этот вопрос уже задавался, но это не решает мою проблему.
Я попытался использовать проверку в моем laravel project
.Но это не работает, это мой код
$rules = array(
'coupon_title' => 'max:10',
'coupon_type_id' => 'numaric',
'expiry_start_date' => 'required|before_or_equal:expiry_end_date',
'expiry_end_date' => 'required',
);
$messages = [
'before_or_equal' => 'The :attribute must be smaller than the End Date',
'before' => 'The :attribute must be Greater than the Interview Start Date',
'after' => 'The :attribute must be Greater than the Interview End Date',
'after_or_equal' => 'The :attribute must be Greater than the Start Time',
//'max' => 'asdasd'
];
$validator = Validator::make($request->all(), $rules, $messages);
if ($validator->fails())
{
$messages = $validator->messages();
return response()->json(['message'=>$messages],401);
}
В моем коде проверено только поле expiry_start_date
.Но поля coupon_title
и coupon_type_id
не проверены.