public static void validateFormat(String format) throws IllegalArgumentException {
    if (format != null
        && !format.toLowerCase().equals("json")
        && !format.toLowerCase().equals("binary")) {
      throw new IllegalArgumentException("invalid format: " + format);
    }
  }
Checks that input or output format is valid. Only supported formats are {@code json} and {@code
binary} (case-insensitive).

@throws IllegalArgumentException iff format is invalid
tools/tinkey/src/main/java/com/google/crypto/tink/tinkey/TinkeyUtil.java