xiaohui-sun commented on a change in pull request #3603: [TE] Endpoints for 
create and edit alert yaml along with validators
URL: https://github.com/apache/incubator-pinot/pull/3603#discussion_r240668028
 
 

 ##########
 File path: 
thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/validators/DetectionAlertConfigValidator.java
 ##########
 @@ -0,0 +1,109 @@
+package com.linkedin.thirdeye.detection.validators;
+
+import com.linkedin.thirdeye.datalayer.dto.DetectionAlertConfigDTO;
+import java.util.List;
+import java.util.Map;
+import org.apache.commons.lang.StringUtils;
+
+import static 
com.linkedin.thirdeye.detection.yaml.YamlDetectionAlertConfigTranslator.*;
+
+
+public class DetectionAlertConfigValidator extends ConfigValidator {
+
+  private static final DetectionAlertConfigValidator INSTANCE = new 
DetectionAlertConfigValidator();
+
+  public static DetectionAlertConfigValidator getInstance() {
+    return INSTANCE;
+  }
+
+  /**
+   * Perform validation on the alert config like verifying if all the required 
fields are set
+   */
+  @SuppressWarnings("unchecked")
+  public boolean validateConfig(DetectionAlertConfigDTO alertConfig,  
Map<String, String> responseMessage) {
+    boolean isValid = true;
+
+    // Check for all the required fields in the alert
+    if (StringUtils.isEmpty(alertConfig.getName())) {
+      responseMessage.put("message", "Subscription group name field cannot be 
left empty.");
+      return false;
 
 Review comment:
   Can we do all the check and return the message together instead of early 
return here?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to