Skip to content

Commit 70cbd4b

Browse files
bebrawjoshwiens
authored andcommitted
fix(schema): emit proper error messages
Related to #371.
1 parent 99f686e commit 70cbd4b

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

schema/validator.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ var ajv = new Ajv({allErrors: true});
33
var json = require('./schema.json');
44

55
module.exports = function validate(data) {
6-
var validSchema = ajv.compile(json);
7-
var valid = validSchema(data);
6+
var ajv = new Ajv();
7+
var isValid = ajv.validate(json, data);
88

9-
if(!valid) {
9+
if(!isValid) {
1010
throw new Error(ajv.errorsText());
1111
}
1212
}

test/extract.test.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,14 @@ describe("ExtractTextPlugin.extract()", function() {
2424
});
2525

2626
it("throws if an incorrect config is passed in", function() {
27-
should.throws(function() {
28-
ExtractTextPlugin.extract({style: 'file.css'});
29-
});
27+
should.throws(
28+
function() {
29+
ExtractTextPlugin.extract({style: 'file.css'});
30+
},
31+
function(err) {
32+
return err.message === 'data should NOT have additional properties';
33+
}
34+
);
3035
});
3136
});
3237

0 commit comments

Comments
 (0)