private boolean isSwitchTaskValid(
                WorkflowTask workflowTask, ConstraintValidatorContext context) {
            boolean valid = true;
            if (workflowTask.getEvaluatorType() == null) {
                String message =
                        String.format(
                                PARAM_REQUIRED_STRING_FORMAT,
                                "evaluatorType",
                                TaskType.SWITCH,
                                workflowTask.getName());
                context.buildConstraintViolationWithTemplate(message).addConstraintViolation();
                valid = false;
            } else if (workflowTask.getExpression() == null) {
                String message =
                        String.format(
                                PARAM_REQUIRED_STRING_FORMAT,
                                "expression",
                                TaskType.SWITCH,
                                workflowTask.getName());
                context.buildConstraintViolationWithTemplate(message).addConstraintViolation();
                valid = false;
            }
            if (workflowTask.getDecisionCases() == null) {
                String message =
                        String.format(
                                PARAM_REQUIRED_STRING_FORMAT,
                                "decisionCases",
                                TaskType.SWITCH,
                                workflowTask.getName());
                context.buildConstraintViolationWithTemplate(message).addConstraintViolation();
                valid = false;
            } else if (workflowTask.getDecisionCases() != null
                    && workflowTask.getDecisionCases().size() == 0) {
                String message =
                        String.format(
                                "decisionCases should have atleast one task for taskType: %s taskName: %s",
                                TaskType.SWITCH, workflowTask.getName());
                context.buildConstraintViolationWithTemplate(message).addConstraintViolation();
                valid = false;
            }

            if ("javascript".equals(workflowTask.getEvaluatorType())
                    && workflowTask.getExpression() != null) {
                try {
                    validateScriptExpression(
                            workflowTask.getExpression(), workflowTask.getInputParameters());
                } catch (Exception ee) {
                    String message =
                            String.format(
                                    ee.getMessage() + ", taskType: SWITCH taskName %s",
                                    workflowTask.getName());
                    context.buildConstraintViolationWithTemplate(message).addConstraintViolation();
                    valid = false;
                }
            }
            return valid;
        }
This constraint class validates following things. 1. Correct parameters are set depending on task
type.
core/src/main/java/com/netflix/conductor/validations/WorkflowTaskTypeConstraint.java