Skip to content

Commit b714c4a

Browse files
committed
Added schema validation
1 parent cf61b36 commit b714c4a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ var addComma = `
2020

2121
function build (schema, options) {
2222
options = options || {}
23+
isValidSchema(schema, options.schema)
2324
/* eslint no-new-func: "off" */
2425
var code = `
2526
'use strict'
@@ -600,4 +601,14 @@ function loadUglify () {
600601
}
601602
}
602603

604+
function isValidSchema (schema, externalSchema) {
605+
const ajv = new Ajv()
606+
if (externalSchema) {
607+
Object.keys(externalSchema).forEach(key => {
608+
ajv.addSchema(externalSchema[key], key)
609+
})
610+
}
611+
ajv.compile(schema)
612+
}
613+
603614
module.exports = build

0 commit comments

Comments
 (0)