Skip to content

Commit a2c52fe

Browse files
committed
validate: add 'container' error code
1 parent f620a22 commit a2c52fe

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/plot_api/validate.js

+6
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ var code2msgFunc = {
2424
schema: function(path) {
2525
return 'key ' + path.join('.') + ' is not part of the schema';
2626
},
27+
container: function(path) {
28+
return 'key ' + path.join('.') + ' is supposed to be linked to a container';
29+
},
2730
unused: function(path, valIn) {
2831
var prefix = isPlainObject(valIn) ? 'container' : 'key';
2932

@@ -115,6 +118,9 @@ function crawl(objIn, objOut, schema, list, path) {
115118
else if(isPlainObject(valIn) && isPlainObject(valOut)) {
116119
crawl(valIn, valOut, nestedSchema, list, p);
117120
}
121+
else if(!isPlainObject(valIn) && isPlainObject(valOut)) {
122+
list.push(format('container', p, valIn));
123+
}
118124
else if(nestedSchema.items && Array.isArray(valIn)) {
119125
var itemName = k.substr(0, k.length - 1);
120126

test/jasmine/tests/validate_test.js

+2
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,13 @@ describe('Plotly.validate', function() {
125125
bgcolor: 'red'
126126
},
127127
geo0: {},
128+
yaxis5: 'sup'
128129
});
129130

130131
assertErrorShape(out, [], 4);
131132
assertErrorContent(out.layout[0], 'value', ['xaxis2', 'range'], '');
132133
assertErrorContent(out.layout[1], 'unused', ['scene10'], '');
133134
assertErrorContent(out.layout[2], 'schema', ['geo0'], '');
135+
assertErrorContent(out.layout[3], 'container', ['yaxis5'], '');
134136
});
135137
});

0 commit comments

Comments
 (0)