Now isValid for schema validation, prints the message when debug is on;

Added dependency of debug
This commit is contained in:
alexandercerutti
2018-08-27 14:00:36 +02:00
parent 788245b140
commit b8e6eec016
3 changed files with 47 additions and 6 deletions

View File

@@ -66,11 +66,11 @@ module.exports = {
locationsDict,
transitType
},
isValid: (opts, schemaName, debug = false) => {
isValid: (opts, schemaName) => {
let validation = Joi.validate(opts, schemaName);
if (debug) {
console.log(validation)
if (validation.error) {
debug(`validation failed due to :: ${validation.error.message}`);
}
return !validation.error;