use AlibabaCloud\SDK\RequestCheckUtil; $requestParams = [ 'Param1' => 'value1' ]; try { RequestCheckUtil::checkRequiredParameters($requestParams, ['Param1', 'Param2']); } catch (\Exception $e) { echo 'Error: ' . $e->getMessage(); } // Output: Error: Required parameter "Param2" is missing
use AlibabaCloud\SDK\RequestCheckUtil; $requestParams = [ 'Param1' => 'value1', 'Param2' => 'value3' ]; try { RequestCheckUtil::checkValueInList($requestParams['Param2'], ['value1', 'value2']); } catch (\Exception $e) { echo 'Error: ' . $e->getMessage(); } // Output: Error: Parameter "Param2" value is invalidIn this example, we are checking if the value of "Param2" is in the set of allowed values using the checkValueInList() method. Since it is not included in the list, an Exception will be thrown with the error message. Overall, RequestCheckUtil is a useful tool for validating API requests and ensuring that they meet the required parameters and values. The package library is acs-sdk-php-core.