Add validation around dates

This commit is contained in:
Marcus Moore 2024-04-10 14:02:25 -07:00
parent d371d14c1f
commit 6d572424ac
No known key found for this signature in database
2 changed files with 20 additions and 2 deletions

View file

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

View file

@ -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