Skip to content
Permalink
Browse files

Include env var in validation error message

  • Loading branch information
philbooth committed Nov 19, 2019
1 parent be350a7 commit e1010297455967069dfbb24734eab05d22804c07
Showing with 13 additions and 2 deletions.
  1. +12 −1 lib/convict.js
  2. +1 −1 test/cases/env_syntax.out
@@ -321,6 +321,11 @@ function normalizeSchema(name, node, props, fullName, env, argv, sensitive) {
// attach the value and the property's fullName to the error
e.fullName = fullName;
e.value = x;

if (o.env) {
e.env = o.env;
}

throw e;
}
};
@@ -648,7 +653,13 @@ let convict = function convict(def, opts) {
let e = errors[i];

if (e.fullName) {
err_buf += e.fullName + ': ';
err_buf += e.fullName;

if (e.env) {
err_buf += '[' + e.env + ']';
}

err_buf += ': ';
}
if (e.message) err_buf += e.message;
if (e.value && !sensitive.has(e.fullName)) {
@@ -1 +1 @@
foo.bar: must be one of the possible values: ["a","b"]: value was "c"
foo.bar[BAR]: must be one of the possible values: ["a","b"]: value was "c"

0 comments on commit e101029

Please sign in to comment.
You can’t perform that action at this time.