Always run validation on checkin

This commit is contained in:
Marcus Moore 2024-11-20 12:25:06 -08:00
parent da4c877ed8
commit f932a4fc76
No known key found for this signature in database
2 changed files with 7 additions and 9 deletions

View file

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

View file

@ -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), [