Esempio n. 1
0
    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
Esempio n. 2
0
 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