private void doValidateConfigurationProperty()

in core/camel-core-catalog/src/main/java/org/apache/camel/catalog/impl/AbstractCamelCatalog.java [1184:1297]


    private void doValidateConfigurationProperty(
            ConfigurationPropertiesValidationResult result,
            Map<String, BaseOptionModel> rows,
            String name, String value, String longKey,
            String lookupKey, String suffix) {

        // find option
        String rowKey = rows.keySet().stream()
                .filter(n -> n.toLowerCase(Locale.ENGLISH).equals(lookupKey)).findFirst().orElse(null);
        if (rowKey == null) {
            // unknown option
            result.addUnknown(longKey);
            if (suggestionStrategy != null) {
                String[] suggestions = suggestionStrategy.suggestEndpointOptions(rows.keySet(), name);
                if (suggestions != null) {
                    result.addUnknownSuggestions(name, suggestions);
                }
            }
        } else {
            boolean optionPlaceholder = value.startsWith("{{") || value.startsWith("${") || value.startsWith("$simple{");
            boolean lookup = value.startsWith("#") && value.length() > 1;

            // deprecated
            BaseOptionModel row = rows.get(rowKey);
            if (!optionPlaceholder && !lookup && row.isDeprecated()) {
                result.addDeprecated(longKey);
            }

            // is boolean
            if (!optionPlaceholder && !lookup && "boolean".equals(row.getType())) {
                // value must be a boolean
                boolean bool = ObjectHelper.isBoolean(value);
                if (!bool) {
                    result.addInvalidBoolean(longKey, value);
                }
            }

            // is duration
            if (!optionPlaceholder && !lookup && "duration".equals(row.getType())) {
                // value must be convertable to a duration
                boolean valid = validateDuration(value);
                if (!valid) {
                    result.addInvalidDuration(longKey, value);
                }
            }

            // is integer
            if (!optionPlaceholder && !lookup && "integer".equals(row.getType())) {
                // value must be an integer
                boolean valid = validateInteger(value);
                if (!valid) {
                    result.addInvalidInteger(longKey, value);
                }
            }

            // is number
            if (!optionPlaceholder && !lookup && "number".equals(row.getType())) {
                // value must be an number
                boolean valid = false;
                try {
                    valid = !Double.valueOf(value).isNaN() || !Float.valueOf(value).isNaN();
                } catch (Exception e) {
                    // ignore
                }
                if (!valid) {
                    result.addInvalidNumber(longKey, value);
                }
            }

            // is enum
            List<String> enums = row.getEnums();
            if (!optionPlaceholder && !lookup && enums != null) {
                boolean found = false;
                String dashEC = StringHelper.camelCaseToDash(value);
                String valueEC = StringHelper.asEnumConstantValue(value);
                for (String s : enums) {
                    // equals as is or using the enum naming style
                    if (value.equalsIgnoreCase(s) || dashEC.equalsIgnoreCase(s) || valueEC.equalsIgnoreCase(s)) {
                        found = true;
                        break;
                    }
                }
                if (!found) {
                    handleNotFound(result, value, longKey, enums);
                }
            }

            String javaType = row.getJavaType();
            if (!optionPlaceholder && !lookup && javaType != null
                    && (javaType.startsWith("java.util.Map") || javaType.startsWith("java.util.Properties"))) {
                // there must be a valid suffix
                if (isValidSuffix(suffix)) {
                    result.addInvalidMap(longKey, value);
                } else if (suffix.startsWith("[") && !suffix.contains("]")) {
                    result.addInvalidMap(longKey, value);
                }
            }
            if (!optionPlaceholder && !lookup && javaType != null && "array".equals(row.getType())) {
                // there must be a suffix and it must be using [] style
                if (isValidSuffix(suffix)) {
                    result.addInvalidArray(longKey, value);
                } else if (!suffix.startsWith("[") && !suffix.contains("]")) {
                    result.addInvalidArray(longKey, value);
                } else {
                    String index = StringHelper.before(suffix.substring(1), "]");
                    // value must be an integer
                    boolean valid = validateInteger(index);
                    if (!valid) {
                        result.addInvalidInteger(longKey, index);
                    }
                }
            }
        }
    }