public function validateEntity($entity)
{
/* @var $entity Environment */
if (empty($entity->name)) {
throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_STRUCTURE, "Missed property name");
}
if (Environment::findOne([['accountId' => $entity->accountId], ['name' => $entity->name], ['id' => ['$ne' => $entity->id]]])) {
throw new ApiErrorException(409, ErrorMessage::ERR_UNICITY_VIOLATION, "Environment with name '{$entity->name}' already exists in this account");
}
if (empty($entity->getProperty(EnvironmentProperty::SETTING_CC_ID))) {
throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_STRUCTURE, "Missed property costCenter");
}
}