Merge pull request #510 from crispthinking/parent-error-cache
cache parent errors
This commit is contained in:
commit
4e6f43412c
|
@ -435,28 +435,35 @@ treemode.validate = function () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// display the error in the nodes with a problem
|
var errorNodes = duplicateErrors.concat(schemaErrors);
|
||||||
this.errorNodes = duplicateErrors
|
var parentPairs = errorNodes
|
||||||
.concat(schemaErrors)
|
.reduce(function (all, entry) {
|
||||||
.reduce(function expandParents (all, entry) {
|
return entry.node
|
||||||
// expand parents, then merge such that parents come first and
|
.findParents()
|
||||||
// original entries last
|
.filter(function (parent) {
|
||||||
return entry.node
|
return !all.some(function (pair) {
|
||||||
.findParents()
|
return pair[0] === parent;
|
||||||
.map(function (parent) {
|
});
|
||||||
return {
|
})
|
||||||
node: parent,
|
.map(function (parent) {
|
||||||
child: entry.node,
|
return [parent, entry.node];
|
||||||
error: {
|
})
|
||||||
message: parent.type === 'object'
|
.concat(all);
|
||||||
? 'Contains invalid properties' // object
|
}, []);
|
||||||
: 'Contains invalid items' // array
|
|
||||||
}
|
this.errorNodes = parentPairs
|
||||||
};
|
.map(function (pair) {
|
||||||
})
|
return {
|
||||||
.concat(all, [entry]);
|
node: pair[0],
|
||||||
}, [])
|
child: pair[1],
|
||||||
// TODO: dedupe the parent nodes
|
error: {
|
||||||
|
message: pair[0].type === 'object'
|
||||||
|
? 'Contains invalid properties' // object
|
||||||
|
: 'Contains invalid items' // array
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.concat(errorNodes)
|
||||||
.map(function setError (entry) {
|
.map(function setError (entry) {
|
||||||
entry.node.setError(entry.error, entry.child);
|
entry.node.setError(entry.error, entry.child);
|
||||||
return entry.node;
|
return entry.node;
|
||||||
|
|
Loading…
Reference in New Issue