mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-02 08:21:09 -08:00
Always run validation on checkin
This commit is contained in:
parent
da4c877ed8
commit
f932a4fc76
|
@ -317,14 +317,12 @@ class ComponentsController extends Controller
|
|||
|
||||
$max_to_checkin = $component_assets->assigned_qty;
|
||||
|
||||
if ($max_to_checkin > 1) {
|
||||
$validator = Validator::make($request->all(), [
|
||||
"checkin_qty" => "required|numeric|between:1,$max_to_checkin"
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, 'Checkin quantity must be between 1 and '.$max_to_checkin));
|
||||
}
|
||||
$validator = Validator::make($request->all(), [
|
||||
"checkin_qty" => "required|numeric|between:1,$max_to_checkin"
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, 'Checkin quantity must be between 1 and ' . $max_to_checkin));
|
||||
}
|
||||
|
||||
// Validation passed, so let's figure out what we have to do here.
|
||||
|
|
|
@ -52,7 +52,7 @@ class ComponentCheckinTest extends TestCase implements TestsFullMultipleCompanie
|
|||
$component = Component::factory()->checkedOutToAsset()->create();
|
||||
|
||||
$pivot = $component->assets->first()->pivot;
|
||||
$pivot->update(['assigned_qty' => 2]);
|
||||
$pivot->update(['assigned_qty' => 1]);
|
||||
|
||||
$this->actingAsForApi(User::factory()->checkinComponents()->create())
|
||||
->postJson(route('api.components.checkin', $component->assets->first()->pivot->id), [
|
||||
|
|
Loading…
Reference in a new issue