/**
   * Validate passwords dynamically from the initial setup form, rendering the result as JSON.
   *
   * @param setup the initial setup form.
   */
  @Restrictions({@Restrict({"SECURITY_ADMIN"}), @Restrict({"RESTRICTED_SECURITY_ADMIN"})})
  public static void validatePasswordDynamic(String password, String fieldName) {
    boolean passed = true;
    if (fieldName.contains("root")) {
      fieldName = "setup.rootPassword";
    }
    if (fieldName.contains("system")) {
      fieldName = "setup.systemPasswords";
    }
    if (PasswordUtil.isNotValid(password)) {
      Validation.addError(fieldName + ".value", "setup.password.notValid");
      passed = false;
    }
    if (passed) {
      String validation = PasswordUtil.validatePassword(password);
      if (StringUtils.isNotBlank(validation)) {
        Validation.addError(fieldName + ".value", validation);
      }
    }

    if (Validation.hasErrors()) {
      renderJSON(ValidationResponse.collectErrors());
    } else {
      renderJSON(ValidationResponse.valid());
    }
  }
 private void remoteValidation(String fieldName) {
   String validation = PasswordUtil.validatePassword(value);
   if (StringUtils.isNotBlank(validation)) {
     Validation.addError(fieldName + ".value", validation);
   }
 }