Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
assert(value: T): void {
assert(typeOf.isJSONValue(value), 'is not a JSON value {a}', value);
if (this.schema) {
// validate schema
var res: TV4SingleResult = tv4.validateResult(value, this.schema);
if (!res.valid || res.missing.length > 0) {
var report = reporter.getReporter(log.out.getWrite(), log.out.getStyle());
var test = report.createTest(this.schema, value, null, res, true);
if (res.missing.length > 0) {
report.reportMissing(test, ' ');
throw new Error('missing schemas');
}
else {
report.reportError(test, res.error, ' ', ' ');
throw res.error;
}
}
}
}
module.exports = function (grunt) {
var out = miniwrite.grunt(grunt);
var style = ministyle.grunt();
var report = reporter.getReporter(out, style);
var runner = runnerModule.getRunner(taskTv4, loader.getLoaders(), out, style);
grunt.registerMultiTask('tv4', 'Validate values against json-schema v4.', function () {
var done = this.async();
//import options
var context = runner.getContext(this.options(runner.getOptions({
timeout: 5000
})));
var objects = [];
if (context.options.fresh) {
context.tv4 = taskTv4.freshApi();
}
else {
context.tv4 = taskTv4;