mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Add validation around dates
This commit is contained in:
parent
d371d14c1f
commit
6d572424ac
|
@ -27,6 +27,14 @@ class AssetCheckoutRequest extends Request
|
||||||
'assigned_location' => 'required_without_all:assigned_user,assigned_asset',
|
'assigned_location' => 'required_without_all:assigned_user,assigned_asset',
|
||||||
'status_id' => 'exists:status_labels,id,deployable,1',
|
'status_id' => 'exists:status_labels,id,deployable,1',
|
||||||
'checkout_to_type' => 'required|in:asset,location,user',
|
'checkout_to_type' => 'required|in:asset,location,user',
|
||||||
|
'checkout_at' => [
|
||||||
|
'nullable',
|
||||||
|
'date',
|
||||||
|
],
|
||||||
|
'expected_checkin' => [
|
||||||
|
'nullable',
|
||||||
|
'date'
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
return $rules;
|
return $rules;
|
||||||
|
|
|
@ -68,9 +68,19 @@ class AssetCheckoutTest extends TestCase
|
||||||
{
|
{
|
||||||
$this->actingAs(User::factory()->create())
|
$this->actingAs(User::factory()->create())
|
||||||
->post(route('hardware.checkout.store', Asset::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
|
public function checkoutTargets(): array
|
||||||
|
|
Loading…
Reference in a new issue