Skip to content

A free open source IT asset/license management system

Add validation around dates

Marcus Moore6d572424ac91
diff --git a/app/Http/Requests/AssetCheckoutRequest.php b/app/Http/Requests/AssetCheckoutRequest.php
index a4c6f8e00d..f48a7d5e53 100644
--- a/app/Http/Requests/AssetCheckoutRequest.php
+++ b/app/Http/Requests/AssetCheckoutRequest.php
@@ -27,6 +27,14 @@ class AssetCheckoutRequest extends Request
'assigned_location' => 'required_without_all:assigned_user,assigned_asset',
'status_id' => 'exists:status_labels,id,deployable,1',
'checkout_to_type' => 'required|in:asset,location,user',
+ 'checkout_at' => [
+ 'nullable',
+ 'date',
+ ],
+ 'expected_checkin' => [
+ 'nullable',
+ 'date'
+ ],
];
return $rules;
diff --git a/tests/Feature/Checkouts/AssetCheckoutTest.php b/tests/Feature/Checkouts/AssetCheckoutTest.php
index b933ec1c91..6f2460e551 100644
--- a/tests/Feature/Checkouts/AssetCheckoutTest.php
+++ b/tests/Feature/Checkouts/AssetCheckoutTest.php
@@ -68,9 +68,19 @@ class AssetCheckoutTest extends TestCase
{
$this->actingAs(User::factory()->create())
->post(route('hardware.checkout.store', Asset::factory()->create()), [
- //
+ 'status_id' => 'does-not-exist',
+ 'checkout_at' => 'invalid-date',
+ 'expected_checkin' => 'invalid-date',
])
- ->assertSessionHasErrors();
+ ->assertSessionHasErrors([
+ 'assigned_user',
+ 'assigned_asset',
+ 'assigned_location',
+ 'status_id',
+ 'checkout_to_type',
+ 'checkout_at',
+ 'expected_checkin',
+ ]);
}
public function checkoutTargets(): array