Skip to content

Beautiful Open-Source Form Builder

fix date validation (#395)

Favour Olayinka9f7cdd09fda1
diff --git a/app/Http/Requests/AnswerFormRequest.php b/app/Http/Requests/AnswerFormRequest.php
index 508ed8537..cc070f52b 100644
--- a/app/Http/Requests/AnswerFormRequest.php
+++ b/app/Http/Requests/AnswerFormRequest.php
@@ -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'];
diff --git a/tests/Feature/Forms/AnswerFormTest.php b/tests/Feature/Forms/AnswerFormTest.php
index 16fb75088..81a28f499 100644
--- a/tests/Feature/Forms/AnswerFormTest.php
+++ b/tests/Feature/Forms/AnswerFormTest.php
@@ -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.',
]);
});