Hey there,
From the docs it looks like validate is the way to validate read-only data against a schema. In the following case I get an error when trying to validate.
(node:25258) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'has' of undefined
at Function.transform (x/src/node_modules/yang-js/lib/lang/extensions.js:689:26)
at Function.Expression.apply (x/src/node_modules/yang-js/lib/expression.js:168:31)
at Function.Expression.eval (x/src/node_modules/yang-js/lib/expression.js:201:21)
at Function.Yang.eval (x/src/node_modules/yang-js/lib/yang.js:213:37)
at Function.transform (x/src/node_modules/yang-js/lib/lang/extensions.js:1190:33)
at Function.Expression.apply (x/src/node_modules/yang-js/lib/expression.js:168:31)
at Function.Yang.validate (x/src/node_modules/yang-js/lib/yang.js:221:19)
at OpenConfigInterpreter.ConvertRestToYang (x/src/dist/index.js:201:59)
at ServerDuplexStream.<anonymous> (x/src/dist/GnmiProtoHandlers.js:132:54)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
It appears that ctx.store is undefined in this call.
transform: function(data, ctx) {
if (this.module.nodes.length && Object.isExtensible(data)) {
if (!ctx.store.has(this.module.tag)) {
this.debug("IMPORT: absorbing data for '" + this.tag + "'");
this.module["eval"](data, ctx);
}
A quick change of the code to
if (ctx.store && !ctx.store.has(this.module.tag))
changes the error to :
(node:26481) UnhandledPromiseRejectionWarning: Error: cannot set data on read-only (config false) element
which appears to be returning the yang with bound data.
I am wondering if :
1) I am correctly using the validation function or if there is a missing option I should be providing,
2) If this is a bug in the validation code.
Hi @Joel-Cripps, thanks for reporting this issue. Looks like this functionality is currently broken. I'll look into this further and let you know what I find.
Hey there, From the docs it looks like validate is the way to validate read-only data against a schema. In the following case I get an error when trying to validate.
Error:
It appears that
ctx.store
is undefined in this call.A quick change of the code to
changes the error to :
which appears to be returning the yang with bound data.
I am wondering if : 1) I am correctly using the validation function or if there is a missing option I should be providing, 2) If this is a bug in the validation code.
Thanks, Joel