fix date validation (#395)
Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
parent
80cdce9502
commit
9f7cdd09fd
|
|
@ -214,9 +214,9 @@ class AnswerFormRequest extends FormRequest
|
|||
private function getRulesForDate($property)
|
||||
{
|
||||
if (isset($property['disable_past_dates']) && $property['disable_past_dates']) {
|
||||
return ['date', 'after_or_equal:today'];
|
||||
return ['date', 'after:yesterday'];
|
||||
} elseif (isset($property['disable_future_dates']) && $property['disable_future_dates']) {
|
||||
return ['date', 'before_or_equal:today'];
|
||||
return ['date', 'before:tomorrow'];
|
||||
}
|
||||
|
||||
return ['date'];
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ it('can not submit form with past dates', function () {
|
|||
$this->postJson(route('forms.answer', $form->slug), $formData)
|
||||
->assertStatus(422)
|
||||
->assertJson([
|
||||
'message' => 'The Date must be a date after or equal to today.',
|
||||
'message' => 'The Date must be a date after yesterday.',
|
||||
]);
|
||||
});
|
||||
|
||||
|
|
@ -142,6 +142,6 @@ it('can not submit form with future dates', function () {
|
|||
$this->postJson(route('forms.answer', $form->slug), $formData)
|
||||
->assertStatus(422)
|
||||
->assertJson([
|
||||
'message' => 'The Date must be a date before or equal to today.',
|
||||
'message' => 'The Date must be a date before tomorrow.',
|
||||
]);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue