def valid_fields(ip: str, port: int, username: str, password: str, use_credentials: bool, mqtt_tls_path, use_tls: bool)  -> tuple[bool,str]:
    if not ip:
        message = "Please fill broker IP"
    elif not port:
        message = "Please fill broker port"
    elif use_credentials and not username:
        message = "Please fill broker username"
    elif use_credentials and not password:
        message = "Please fill broker password"
    elif use_tls and not mqtt_tls_path:
        message = "Please select TLS certificate"
    else:
        return True, ""
    
    return False, message
    