src/common/core/users/metarules.js
function checkPointerRules(meta, core, node, callback) {
        var result = {
                hasViolation: false,
                messages: []
            },
            metaPointers = filterPointerRules(meta).pointers,
            checkPromises = [],
            pointerNames = core.getPointerNames(node);

        checkPromises = pointerNames.map(function (pointerName) {
            var metaPointer = metaPointers[pointerName],
                pointerPath,
                pointerPaths = [];

            if (!metaPointer) {
                if (pointerName === 'base') {
                    return {hasViolation: false};
                } else {
                    return Q({
                        hasViolation: true,
                        messages: ['Illegal pointer "' + pointerName + '".']
                    });
                }
            } else {
                pointerPath = core.getPointerPath(node, pointerName);
                if (pointerPath !== null) {
                    pointerPaths.push(pointerPath);
                }
                return loadNodes(core, node, pointerPaths)
                    .then(function (nodes) {
                        return checkNodeTypesAndCardinality(core, node, nodes, metaPointer,
                            '"' + pointerName + '" target', true);
                    });
            }
        });

        return Q.all(checkPromises)
            .then(function (results) {
                results.forEach(function (res) {
                    if (res.hasViolation) {
                        result.hasViolation = true;
                        result.messages = result.messages.concat(res.messages);
                    }
                });

                return result;
            }).nodeify(callback);
    }
function checkPointerRules(meta, core, node, callback) {
        var result = {
                hasViolation: false,
                messages: []
            },
            metaPointers = filterPointerRules(meta).pointers,
            checkPromises = [],
            pointerNames = core.getPointerNames(node);

        checkPromises = pointerNames.map(function (pointerName) {
            var metaPointer = metaPointers[pointerName],
                pointerPath,
                pointerPaths = [];

            if (!metaPointer) {
                if (pointerName === 'base') {
                    return {hasViolation: false};
                } else {
                    return Q({
                        hasViolation: true,
                        messages: ['Illegal pointer "' + pointerName + '".']
                    });
                }
            } else {
                pointerPath = core.getPointerPath(node, pointerName);
                if (pointerPath !== null) {
                    pointerPaths.push(pointerPath);
                }
                return loadNodes(core, node, pointerPaths)
                    .then(function (nodes) {
                        return checkNodeTypesAndCardinality(core, node, nodes, metaPointer,
                            '"' + pointerName + '" target', true);
                    });
            }
        });

        return Q.all(checkPromises)
            .then(function (results) {
                results.forEach(function (res) {
                    if (res.hasViolation) {
                        result.hasViolation = true;
                        result.messages = result.messages.concat(res.messages);
                    }
                });

                return result;
            }).nodeify(callback);
    }
function checkPointerRules ( meta , core , node , callback ) { var result = { hasViolation : false , messages : [ ] } , metaPointers = filterPointerRules ( meta ) . pointers , checkPromises = [ ] , pointerNames = core . getPointerNames ( node ) ; checkPromises = pointerNames . map ( function ( pointerName ) { var metaPointer = metaPointers [ pointerName ] , pointerPath , pointerPaths = [ ] ; if ( ! metaPointer ) { if ( pointerName === 'base' ) { return { hasViolation : false } ; } else { return Q ( { hasViolation : true , messages : [ 'Illegal pointer "' + pointerName + '".' ] } ) ; } } else { pointerPath = core . getPointerPath ( node , pointerName ) ; if ( pointerPath !== null ) { pointerPaths . push ( pointerPath ) ; } return loadNodes ( core , node , pointerPaths ) . then ( function ( nodes ) { return checkNodeTypesAndCardinality ( core , node , nodes , metaPointer , '"' + pointerName + '" target' , true ) ; } ) ; } } ) ; return Q . all ( checkPromises ) . then ( function ( results ) { results . forEach ( function ( res ) { if ( res . hasViolation ) { result . hasViolation = true ; result . messages = result . messages . concat ( res . messages ) ; } } ) ; return result ; } ) . nodeify ( callback ) ; }
Checker functions for pointers, sets, containment and attributes.
Checker functions for pointers sets containment and attributes .