getBody(), true) ?? []; try { v::key('product_id', v::intType()->positive()) ->key('company_id', v::intType()->positive()) ->key('description_text', v::stringType()->notEmpty()) ->assert($body); } catch (ValidationException $e) { return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(422); } $model = new DescriptionModel(); $result = $model->addDescription( (int)$body['product_id'], (int)$body['company_id'], (string)$body['description_text'] ); return $result ? ResponseLib::sendOk(['created' => true]) : ResponseLib::sendFail("Failed to Create Description", [], "E_DB")->withStatus(500); } }