function()

in default/cve5/conf.js [237:364]


        function (schema, value, path) {
            var errors = [];
            if (schema.id == "desc" && value.value == "") {
                value = {}
            }
            if(schema.id == "pE") {
                if((value.vendor != undefined && value.product != undefined) || (value.collectionURL != undefined && value.packageName != undefined)) {
                    // it is valid 
                } else {
                    if (value.vendor == undefined && value.product != undefined) {
                        errors.push({
                            path: path+'.vendor',
                            property: 'format',
                            message: 'Enter vendor name'
                        });
                    } else if (value.product == undefined && value.vendor != undefined) {
                        errors.push({
                            path: path+'.product',
                            property: 'format',
                            message: 'Enter product name'
                        });
                    } else if (value.collectionURL == undefined && value.packageName != undefined) {
                        errors.push({
                            path: path+'.collectionURL',
                            property: 'format',
                            message: 'Enter a URL for the package collection'
                        });
                    } else if (value.packageName == undefined && value.collectionURL != undefined) {
                        errors.push({
                            path: path+'.packageName',
                            property: 'format',
                            message: 'Enter package name'
                        });
                    } else {
                        errors.push({
                            path: path,
                            property: 'format',
                            // ASF
                            message: 'Enter a product name'
                            // END ASF
                        });
                    }
                }
                /* 
                p v c pkg
                0 0 0 0 = vendor or pkg needed
                0 0 0 1 = c needed
                0 0 1 0 = pkg needed
                0 0 1 1 = ok
                0 1 0 0 = prod needed
                0 1 0 1 = p or c needed
                0 1 1 0 = product or pkg needed
                0 1 1 1 = ok
                1 0 0 0 = vendor needed
                1 0 0 1 = vendor or collection url needed
                1 0 1 0 = v or pkg needed
                1 0 1 1 = ok
                1 1 0 0 = ok
                1 1 0 1 = ok
                1 1 1 0 = ok
                1 1 1 1 = ok
                */
            }
            if(schema.id == "vE") {
                if(value.lessThan != undefined && value.lessThanOrEqual != undefined) {
                    /*errors.push({
                        path: path+'.lessThan',
                        property: 'format',
                        message: 'Enter either lessThan or lessThanOrEqual, but not both'
                    });*/
                    errors.push({
                        path: path+'.lessThanOrEqual',
                        property: 'format',
                        message: 'Enter either < v or <= v, but not both'
                    });
                }
                if(value.version != undefined && (value.version == value.lessThan)) {
                    errors.push({
                        path: path+'.lessThan',
                        property: 'format',
                        message: 'End is same as the start'
                    });
                }
                if(value.version != undefined && (value.version == value.lessThanOrEqual)) {
                    errors.push({
                        path: path+'.lessThanOrEqual',
                        property: 'format',
                        message: 'End is same as the start'
                    });
                }
                if((value.lessThan != undefined || value.lessThanOrEqual != undefined) && value.versionType == undefined) {
                    errors.push({
                        path: path+'.versionType',
                        property: 'format',
                        message: 'Version type is required for ranges'
                    });
                }
                if(value.lessThan == undefined && value.lessThanOrEqual == undefined && value.version != undefined && value.versionType != undefined) {
                    errors.push({
                        path: path+'.versionType',
                        property: 'format',
                        message: 'Version type is used only for ranges. Clear this or define a range'
                    });
                }
                if(value.lessThan == undefined && value.lessThanOrEqual == undefined && value.version != undefined && value.changes != undefined) {
                    errors.push({
                        path: path+'.changes',
                        property: 'format',
                        message: 'Changes are used only for ranges. Clear this or define a range'
                    });
                }
            }
            if(schema.id == "xtag") {
                if(value && schema.items && schema.items.examples) {
                    for(i = 0; i < value.length; i++) {
                        if(value[i] && !schema.items.examples.includes(value[i]) && !value[i].match("^x_.*$")) {
                            errors.push({
                                path: path,
                                property: 'format',
                                message: 'Select from the suggested tags or enter custom tags starting with x_'
                            });
                            break;
                        }
                    }
                }
            }
            return errors;
        }