def validate(self) -> None: exceptions: List[ValidationError] = [] # Validate/populate model exists self._model = DatabaseDAO.find_by_id(self._model_id) if not self._model: raise DatabaseNotFoundError() database_name: Optional[str] = self._properties.get("database_name") if database_name: # Check database_name uniqueness if not DatabaseDAO.validate_update_uniqueness( self._model_id, database_name): exceptions.append(DatabaseExistsValidationError()) if exceptions: exception = DatabaseInvalidError() exception.add_list(exceptions) raise exception
def validate(self) -> None: exceptions: List[ValidationError] = list() sqlalchemy_uri: Optional[str] = self._properties.get("sqlalchemy_uri") database_name: Optional[str] = self._properties.get("database_name") if not sqlalchemy_uri: exceptions.append(DatabaseRequiredFieldValidationError("sqlalchemy_uri")) if not database_name: exceptions.append(DatabaseRequiredFieldValidationError("database_name")) else: # Check database_name uniqueness if not DatabaseDAO.validate_uniqueness(database_name): exceptions.append(DatabaseExistsValidationError()) if exceptions: exception = DatabaseInvalidError() exception.add_list(exceptions) raise exception
def validate(self) -> None: exceptions: List[ValidationError] = [] sqlalchemy_uri: Optional[str] = self._properties.get("sqlalchemy_uri") database_name: Optional[str] = self._properties.get("database_name") if not sqlalchemy_uri: exceptions.append(DatabaseRequiredFieldValidationError("sqlalchemy_uri")) if not database_name: exceptions.append(DatabaseRequiredFieldValidationError("database_name")) else: # Check database_name uniqueness if not DatabaseDAO.validate_uniqueness(database_name): exceptions.append(DatabaseExistsValidationError()) if exceptions: exception = DatabaseInvalidError() exception.add_list(exceptions) event_logger.log_with_context( action=f"db_connection_failed.{exception.__class__.__name__}" ) raise exception