예제 #1
0
  @RequestMapping(value = "/validateName", method = RequestMethod.POST)
  public @ResponseBody JsonResponse validateName(
      @RequestParam(value = "name", required = true) String name) {

    String error = "";
    if (StringUtils.isEmpty(name)) {
      error = messageResource.getMessage("org.hibernate.validator.constraints.NotEmpty.message");
    } else if (StringUtils.length(name) > 255) {
      error = messageResource.getMessage("validation.constraints.Size.message", "1", "255");
    }
    return getResponse(error);
  }
예제 #2
0
  @RequestMapping(value = "/validateUrl", method = RequestMethod.POST)
  public @ResponseBody JsonResponse validateUrl(
      @RequestParam(value = "url", required = true) String url) {

    String error = "";
    if (StringUtils.isEmpty(url)) {
      error = messageResource.getMessage("org.hibernate.validator.constraints.NotEmpty.message");
    } else if (!urlValidator.isValid(url)) {
      error = messageResource.getMessage("org.hibernate.validator.constraints.URL.message");
    }

    return getResponse(error);
  }
예제 #3
0
  @RequestMapping(value = "/validateEmailList", method = RequestMethod.POST)
  public @ResponseBody JsonResponse validateEmailList(
      @RequestParam(value = "emailToList", required = true) String emailToList) {

    String error = "";
    if (!StringUtils.isEmpty(emailToList)) {
      List<String> emailList = Arrays.asList(emailToList.split(Monitor.SEPARATOR));
      for (String email : emailList) {
        if (!EmailValidator.getInstance().isValid(email)) {
          error +=
              messageResource.getMessage(
                  "org.hibernate.validator.constraints.Email.message", email);
        }
      }
    }

    return getResponse(error);
  }