hsp/compiler/jsgenerator/index.js
function _validate (code, lineMap) {
    var validationResult = jsv.validate(code);
    var result = {isValid: validationResult.isValid};
    if (!validationResult.isValid) {
        // translate error line numbers
        var error, lineNumber;
        for (var i = 0; i < validationResult.errors.length; i++) {
            error = validationResult.errors[i];
            lineNumber = error.line;

            error.line = -1; // to avoid sending a wrong line in case of pb
            for (var j = 0; j < lineMap.length; j++) {
                if (lineMap[j] === lineNumber) {
                    error.line = j; // original line nbr
                    break;
                }
            }
        }
        result.errors = validationResult.errors;
    }
    return result;
}
function _validate (code, lineMap) {
    var validationResult = jsv.validate(code);
    var result = {isValid: validationResult.isValid};
    if (!validationResult.isValid) {
        // translate error line numbers
        var error, lineNumber;
        for (var i = 0; i < validationResult.errors.length; i++) {
            error = validationResult.errors[i];
            lineNumber = error.line;

            error.line = -1; // to avoid sending a wrong line in case of pb
            for (var j = 0; j < lineMap.length; j++) {
                if (lineMap[j] === lineNumber) {
                    error.line = j; // original line nbr
                    break;
                }
            }
        }
        result.errors = validationResult.errors;
    }
    return result;
}
function _validate ( code , lineMap ) { var validationResult = jsv . validate ( code ) ; var result = { isValid : validationResult . isValid } ; if ( ! validationResult . isValid ) { // translate error line numbers var error , lineNumber ; for ( var i = 0 ; i < validationResult . errors . length ; i ++ ) { error = validationResult . errors [ i ] ; lineNumber = error . line ; error . line = - 1 ; // to avoid sending a wrong line in case of pb for ( var j = 0 ; j < lineMap . length ; j ++ ) { if ( lineMap [ j ] === lineNumber ) { error . line = j ; // original line nbr break ; } } } result . errors = validationResult . errors ; } return result ; }
Validates a javascript string using the jsvalidator module, and generates an error report if not valid.
@param {String} code the javascript string.
@param {Object} lineMap the line mapping between the source template and the compiled one
@return {Object} a result map
Validates a javascript string using the jsvalidator module and generates an error report if not valid .