Scalr\Api\Service\User\V1beta0\Adapter\ScalingRuleAdapter::validateNumericSetting PHP Method

validateNumericSetting() public method

Validate Integer Scaling rule settings
public validateNumericSetting ( array $settings, string $name, string $property = null, integer $minValue )
$settings array entity settings
$name string entity property name
$property string optional property name
$minValue integer optional min property value
    public function validateNumericSetting($settings, $name, $property = null, $minValue = 0)
    {
        if (is_null($property)) {
            $property = $this->getSettingsRules()[$name];
        }
        if (!isset($settings[$name])) {
            throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_STRUCTURE, sprintf('Missed property %s', $property));
        }
        if (!is_numeric($settings[$name])) {
            throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_VALUE, sprintf('Unexpected %s value', $property));
        }
        if ($settings[$name] < $minValue) {
            throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_VALUE, sprintf('Property %s must be greater than or equal to %u', $property, $minValue));
        }
    }