validateObject() public method

It is applicable only to either POST or PATCH methods. It should be used on GET methods.
public validateObject ( object $object, string $method = null )
$object object An object provided with the request
$method string optional HTTP METHOD
示例#1
0
 /**
  * {@inheritdoc}
  * @see \Scalr\Api\DataType\ApiEntityAdapter::validateObject()
  */
 public function validateObject($object, $method = null)
 {
     parent::validateObject($object, $method);
     if (isset($object->scope) && $object->scope !== ScopeInterface::SCOPE_ENVIRONMENT) {
         throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_VALUE, "Invalid scope");
     }
 }
示例#2
0
 /**
  * {@inheritdoc}
  * @see \Scalr\Api\DataType\ApiEntityAdapter::validateObject()
  */
 public function validateObject($object, $method = null)
 {
     parent::validateObject($object, $method);
     if (isset($object->scope) && $object->scope !== $this->controller->getScope()) {
         throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_VALUE, "Invalid scope");
     }
 }
示例#3
0
 /**
  * {@inheritdoc}
  * @see ApiEntityAdapter::validateObject()
  */
 public function validateObject($object, $method = null)
 {
     parent::validateObject($object, $method);
     if ($method === Request::METHOD_POST) {
         if (empty($object->name)) {
             throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_STRUCTURE, 'Missed property name');
         }
         if ($object->ruleType === static::BASIC_SCALING_RULE xor !isset(ScalingMetricAdapter::$nameMap[$object->name])) {
             throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_VALUE, 'Unexpected ruleType value');
         }
     }
 }