Skip to content

Commit c21b3a5

Browse files
authored
Merge pull request #4938 from plotly/handle-undefined-args-in-validate
handle undefined args in Plotly.validate
2 parents 13947fc + bfbb732 commit c21b3a5

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/plot_api/validate.js

+3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ var isArrayOrTypedArray = Lib.isArrayOrTypedArray;
3939
* error message (shown in console in logger config argument is enable)
4040
*/
4141
module.exports = function validate(data, layout) {
42+
if(data === undefined) data = [];
43+
if(layout === undefined) layout = {};
44+
4245
var schema = PlotSchema.get();
4346
var errorList = [];
4447
var gd = {_context: Lib.extendFlat({}, dfltConfig)};

test/jasmine/tests/mock_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2078,7 +2078,7 @@ describe('@noCI mock validation', function() {
20782078
it('validating mock: "' + name + '"', function() {
20792079
var out = Plotly.validate(
20802080
figure.data,
2081-
figure.layout || {} // shouldn't Plotly.validate handle undefined layout?
2081+
figure.layout
20822082
);
20832083
assert(name, out);
20842084
});

0 commit comments

Comments
 (0)