Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
keepGoing = false;
} else { // In case the parameter is indeed present, check type. In the case of array, check also type of its items!
try { // eslint-disable-line
if (schema.type !== 'string') { // eslint-disable-line
value = JSON.parse(req[location][name]);
} else {
value = String(req[location][name]);
}
} catch (err) {
value = String(req[location][name]);
}
err = validator.validate(value, schema);
if (err == false) { // eslint-disable-line
keepGoing = false;
if (err.code == "UNKNOWN_FORMAT") { // eslint-disable-line
var registeredFormats = ZSchema.getRegisteredFormats();
logger.error("UNKNOWN_FORMAT error - Registered Formats: ");
logger.error(registeredFormats);
}
newErr = {
message: "Wrong parameter " + name + " in " + location + ". ",
error: validator.getLastErrors()
};
msg.push(newErr);
} else {
logger.info("Valid parameter on request");
}
}
}
}
}
if (keepGoing == false && config.strict == true) {
traverse(json).forEach(function () {
var name = this.key;
var format = this.node;
if (name === 'format' && _.indexOf(ZSchema.getRegisteredFormats(), format) === -1) {
ZSchema.registerFormat(format, function () {
return true;
});
}
});
};