core/PreferenceManager.js
function validate(schema) {
        var key, item;
        for (key in schema) {
            if (schema.hasOwnProperty(key)) {
                item = schema[key];
                if (!item.text) {
                    console.error("[PreferenceManager] missing required field: 'text' of '" + key + "'");
                }
                if (!item.type) {
                    console.error("[PreferenceManager] missing required field: 'type' of '" + key + "'");
                }
                if (item.type !== "Section" && typeof item['default'] === "undefined") {
                    console.error("[PreferenceManager] missing required field: 'default' of '" + key + "'");
                }
                if (item.type === "Combo" || item.type === "Dropdown") {
                    if (item.options && item.options.length > 0) {
                        var i, len;
                        for (i = 0, len = item.options.length; i < len; i++) {
                            if (typeof item.options[i].value === "undefined") {
                                console.error("[PreferenceManager] missing required field of option item: 'value' of '" + key + "'");
                            }
                            if (typeof item.options[i].text === "undefined") {
                                console.error("[PreferenceManager] missing required field of option item: 'text' of '" + key + "'");
                            }
                        }
                    } else {
                        console.error("[PreferenceManager] missing required field or no items: 'options' of '" + key + "'");
                    }
                }
            }
        }
        return true;
    }
function validate(schema) {
        var key, item;
        for (key in schema) {
            if (schema.hasOwnProperty(key)) {
                item = schema[key];
                if (!item.text) {
                    console.error("[PreferenceManager] missing required field: 'text' of '" + key + "'");
                }
                if (!item.type) {
                    console.error("[PreferenceManager] missing required field: 'type' of '" + key + "'");
                }
                if (item.type !== "Section" && typeof item['default'] === "undefined") {
                    console.error("[PreferenceManager] missing required field: 'default' of '" + key + "'");
                }
                if (item.type === "Combo" || item.type === "Dropdown") {
                    if (item.options && item.options.length > 0) {
                        var i, len;
                        for (i = 0, len = item.options.length; i < len; i++) {
                            if (typeof item.options[i].value === "undefined") {
                                console.error("[PreferenceManager] missing required field of option item: 'value' of '" + key + "'");
                            }
                            if (typeof item.options[i].text === "undefined") {
                                console.error("[PreferenceManager] missing required field of option item: 'text' of '" + key + "'");
                            }
                        }
                    } else {
                        console.error("[PreferenceManager] missing required field or no items: 'options' of '" + key + "'");
                    }
                }
            }
        }
        return true;
    }
function validate ( schema ) { var key , item ; for ( key in schema ) { if ( schema . hasOwnProperty ( key ) ) { item = schema [ key ] ; if ( ! item . text ) { console . error ( "[PreferenceManager] missing required field: 'text' of '" + key + "'" ) ; } if ( ! item . type ) { console . error ( "[PreferenceManager] missing required field: 'type' of '" + key + "'" ) ; } if ( item . type !== "Section" && typeof item [ 'default' ] === "undefined" ) { console . error ( "[PreferenceManager] missing required field: 'default' of '" + key + "'" ) ; } if ( item . type === "Combo" || item . type === "Dropdown" ) { if ( item . options && item . options . length > 0 ) { var i , len ; for ( i = 0 , len = item . options . length ; i < len ; i ++ ) { if ( typeof item . options [ i ] . value === "undefined" ) { console . error ( "[PreferenceManager] missing required field of option item: 'value' of '" + key + "'" ) ; } if ( typeof item . options [ i ] . text === "undefined" ) { console . error ( "[PreferenceManager] missing required field of option item: 'text' of '" + key + "'" ) ; } } } else { console . error ( "[PreferenceManager] missing required field or no items: 'options' of '" + key + "'" ) ; } } } } return true ; }
Validate preference schema
@param {Object} schema
@return {boolean}
Validate preference schema