protected void appendJavaScriptValidatorRuleArgs(ValidationMetaData constraint) throws IOException {
    appendJsString(constraint.getField());

    append(',');

    Annotation annotation = constraint.getConstraint();
    Class annotationType = annotation.annotationType();
    String shortName = ClassUtils.getShortName(annotationType);

    appendJsString(shortName);

    append(',');

    Map<String, Object> attributes = constraint.getAttributes();

    append('{');

    if (attributes != null && !attributes.isEmpty()) {
      // convert attribute to JSON object
      int printedAttributes = 0;
      for (String key : attributes.keySet()) {
        if (!IGNORED_ATTRIBUTES.contains(key)) {
          if (printedAttributes > 0) {
            append(',');
          }
          appendJsString(key);
          append(':');
          Object value = attributes.get(key);
          if (value instanceof Object[]) {
            // handle array of values, like for Pattern flags
            Object[] values = (Object[]) value;
            append('[');
            for (int i = 0; i < values.length; i++) {
              Object currentValue = values[i];
              String currentStringValue = currentValue.toString();
              appendJsString(currentStringValue);
              if (i < values.length) {
                append(',');
              }
            }
            append(']');
          } else {
            appendJsString(value.toString());
          }
          printedAttributes++;
        }
      }
    }

    append('}');
  }