*                   responsible for reporting the error to the user through
   *                   ValidationEventHandler.
   */
  private String convert(String v) throws Exception {
    if (v == null) {
      return null;
    }
    if (minLength != null && v.length() < minLength) {
      throw new Exception("string length violation " + this.getClass().getSimpleName().replace(NAME_PREFIX, "") + " [" + minLength + "-" + maxLength + "]" + " with length = " + v.length() + ".");
    }
    if (maxLength != null && v.length() > maxLength) {
      throw new Exception("string length violation " + this.getClass().getSimpleName().replace(NAME_PREFIX, "") + " [" + minLength + "-" + maxLength + "]" + " with length = " + v.length() + ".");
    }
    /**
     * If the string length is valid then validate the pattern if applicable.
     */
    if (pattern != null) {
      if (!Pattern.compile(pattern).matcher(v).find()) {
        throw new Exception("string pattern violation " + this.getClass().getSimpleName().replace(NAME_PREFIX, "") + " [" + pattern + "] for \"" + v + "\".");
      }
    }
    /**
     * Convert to upper case if indicated.
     */
    return upperCase ? v.toUpperCase(Locale.getDefault()) : v;
  }