js/ka-validator.js
/**
     * Performs validation of the given javascript code checking that all the
     * structural rules specified in the rules parameter are present. For any rules
     * that do not pass in the javascript code, an alert object will be created and added to
     * a list of alerts. The alert object will consist of a message
     * field. If the javascript cannot be parsed, a single alert with the parser
     * error message will be returned.
     *
     * @param {string} script - The javascript code string
     * @param {(Object|Object[])} rules - The structural rule or rules to check
     * @returns {Array} Array of all alert objects generated by the validation.
     */
Performs validation of the given javascript code checking that all the
structural rules specified in the rules parameter are present. For any rules
that do not pass in the javascript code, an alert object will be created and added to
a list of alerts. The alert object will consist of a message
field. If the javascript cannot be parsed, a single alert with the parser
error message will be returned.

@param {string} script - The javascript code string
@param {(Object|Object[])} rules - The structural rule or rules to check
@returns {Array} Array of all alert objects generated by the validation.
Performs validation of the given javascript code checking that all the structural rules specified in the rules parameter are present . For any rules that do not pass in the javascript code an alert object will be created and added to a list of alerts . The alert object will consist of a message field . If the javascript cannot be parsed a single alert with the parser error message will be returned . @param { string } script - The javascript code string @param { ( Object|Object [] ) } rules - The structural rule or rules to check @returns { Array } Array of all alert objects generated by the validation .
function evaluateStructural(script, rules, options) {
        var i,
            ast,
            alerts = [];
        ast = parseCode(script, alerts);
        if (ast && rules) {
            if (Array.isArray(rules)) {
                for (i = 0; i < rules.length; i++) {
                    if (!evaluateStructuralRule(ast, rules[i].rule, options)) {
                        alerts.push({
                            type: alertTypes.STRUCTURAL,
                            message: rules[i].message
                        });
                    }
                }
            } else {
                if (!evaluateStructuralRule(ast, rules.rule, options)) {
                    alerts.push({
                        type: alertTypes.STRUCTURAL,
                        message: rules.message
                    });
                }
            }
        }
        return alerts;
    }
function evaluateStructural ( script , rules , options ) { var i , ast , alerts = [ ] ; ast = parseCode ( script , alerts ) ; if ( ast && rules ) { if ( Array . isArray ( rules ) ) { for ( i = 0 ; i < rules . length ; i ++ ) { if ( ! evaluateStructuralRule ( ast , rules [ i ] . rule , options ) ) { alerts . push ( { type : alertTypes . STRUCTURAL , message : rules [ i ] . message } ) ; } } } else { if ( ! evaluateStructuralRule ( ast , rules . rule , options ) ) { alerts . push ( { type : alertTypes . STRUCTURAL , message : rules . message } ) ; } } } return alerts ; }
Performs validation of the given javascript code checking that all the
 structural rules specified in the rules parameter are present.
Performs validation of the given javascript code checking that all the structural rules specified in the rules parameter are present .