public void validate(ProjectReactor reactor) {
    List<String> validationMessages = new ArrayList<>();

    for (ProjectDefinition moduleDef : reactor.getProjects()) {
      validateModule(moduleDef, validationMessages);
    }

    if (isBranchFeatureAvailable()) {
      branchParamsValidator.validate(validationMessages);
    } else {
      validateBranchParamsWhenPluginAbsent(validationMessages);
      validatePullRequestParamsWhenPluginAbsent(validationMessages);
    }

    if (!validationMessages.isEmpty()) {
      throw MessageException.of("Validation of project failed:\n  o " +
        String.join("\n  o ", validationMessages));
    }
  }
@Test
  void fail_when_invalid_key() {
    ProjectReactor reactor = createProjectReactor("foo$bar");

    assertThatThrownBy(() -> underTest.validate(reactor))
      .isInstanceOf(MessageException.class)
      .hasMessageContaining("\"foo$bar\" is not a valid project key. Allowed characters are alphanumeric,"
        + " '-', '_', '.' and ':', with at least one non-digit.");
  }