Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
fix(schema): emit proper error messages
Browse files Browse the repository at this point in the history
Related to #371.
  • Loading branch information
bebraw authored and joshwiens committed Jan 28, 2017
1 parent 99f686e commit 70cbd4b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 3 additions & 3 deletions schema/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ var ajv = new Ajv({allErrors: true});
var json = require('./schema.json');

module.exports = function validate(data) {
var validSchema = ajv.compile(json);
var valid = validSchema(data);
var ajv = new Ajv();
var isValid = ajv.validate(json, data);

if(!valid) {
if(!isValid) {
throw new Error(ajv.errorsText());
}
}
11 changes: 8 additions & 3 deletions test/extract.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,14 @@ describe("ExtractTextPlugin.extract()", function() {
});

it("throws if an incorrect config is passed in", function() {
should.throws(function() {
ExtractTextPlugin.extract({style: 'file.css'});
});
should.throws(
function() {
ExtractTextPlugin.extract({style: 'file.css'});
},
function(err) {
return err.message === 'data should NOT have additional properties';
}
);
});
});

Expand Down

0 comments on commit 70cbd4b

Please sign in to comment.