public static void validateString(
            String key,
            String value,
            boolean isOptional,
            int minLen,
            int maxLen) {

        if (value == null) {
            if (!isOptional) {
                throw new IllegalArgumentException(String.format("Value of key %s must not be null!", key));
            }
        } else {
            if (value.length() < minLen) {
                throw new IllegalArgumentException(
                        String.format("Value's length of key %s should be shorter than %d!",
                                key, minLen));
            }

            if (value.length() > maxLen) {
                throw new IllegalArgumentException(
                        String.format("Value's length of key %s should be longer than %d!",
                                key, minLen));
            }
        }
    }
Used for validate format options {@link ReadableConfig}.
inlong-sort/sort-formats/format-common/src/main/java/org/apache/inlong/sort/formats/util/ValidateUtils.java