fix date validation (#395)

Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
Favour Olayinka 2024-05-06 13:16:26 +01:00 committed by GitHub
parent 80cdce9502
commit 9f7cdd09fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View File

@ -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'];

View File

@ -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.',
]);
});