diff --git a/parambulator.js b/parambulator.js index 864187c..d727510 100644 --- a/parambulator.js +++ b/parambulator.js @@ -583,15 +583,15 @@ } var err = new Error( msg ) - err.parambulator = { - code:code, - property:ctxt.prop, - value:ctxt.point, - expected:ctxt.rule.spec, - parents:ctxt.parents, - point:ctxt.point, - rule:ctxt.rule} + err.parambulator = { + code: code, + property: ctxt.prop, + value: ctxt.point, + expected: (ctxt.rule ? ctxt.rule.spec : void 0), + parents: ctxt.parents, + point: ctxt.point, + rule: ctxt.rule} return cb(err) } diff --git a/test/parambulator.spec.js b/test/parambulator.spec.js index 92d5744..5334ff7 100644 --- a/test/parambulator.spec.js +++ b/test/parambulator.spec.js @@ -59,6 +59,13 @@ describe('parambulator', function() { }) + it('no_input', function() { + pb.validate(void 0,function(err){ + assert.equal('no_input$',err.parambulator.code) + }) + }) + + it('required$', function() { pb.validate({a:1,z:1,red:1,foo:1,bar:1},function(err,res){ assert.isNull(err)