From 76a171de13d1812733be8a58f50571d2a3501775 Mon Sep 17 00:00:00 2001 From: Juho Vepsalainen Date: Sat, 28 Jan 2017 19:31:36 +0200 Subject: [PATCH] feat(errors): show nicer errors if there are extra fields Now you can see which field caused the error. --- schema/validator.js | 4 +++- test/extract.test.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/schema/validator.js b/schema/validator.js index 40b2e099..5e5f9174 100644 --- a/schema/validator.js +++ b/schema/validator.js @@ -2,7 +2,9 @@ var Ajv = require('ajv'); var ajv = new Ajv({allErrors: true}); module.exports = function validate(schema, data) { - var ajv = new Ajv(); + var ajv = new Ajv({ + errorDataPath: 'property' + }); var isValid = ajv.validate(schema, data); if(!isValid) { diff --git a/test/extract.test.js b/test/extract.test.js index fe1fdf91..8395b262 100644 --- a/test/extract.test.js +++ b/test/extract.test.js @@ -29,7 +29,7 @@ describe("ExtractTextPlugin.extract()", function() { ExtractTextPlugin.extract({style: 'file.css'}); }, function(err) { - return err.message === 'data should NOT have additional properties'; + return err.message === 'data[\'style\'] should NOT have additional properties'; } ); });