From dea5ce60ec331cfaf3c8e2b4e40eaf697eb567c4 Mon Sep 17 00:00:00 2001 From: Lauren Budorick Date: Wed, 9 Jul 2014 17:09:03 -0700 Subject: [PATCH] Fix validation for arrays of functions --- lib/validate.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/validate.js b/lib/validate.js index 2b7b164..08b344c 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -98,7 +98,11 @@ function value(key, val, constants, ref, spec, errors) { for (var i = 0; i < val.length; i++) { var valspec = ref[spec.value]||spec.value; if (typeof valspec === 'string') { - pass = validateNative(key + '[' + i + ']', val[i], valspec, errors) && pass; + if (spec.function && typeof val[i] === 'object') { + pass = value(key, val[i], constants, ref, ref.function, errors); + } else { + pass = validateNative(key + '[' + i + ']', val[i], valspec, errors) && pass; + } } else { pass = value(key + '[' + i + ']', val[i], constants, ref, valspec, errors) && pass; } @@ -107,7 +111,7 @@ function value(key, val, constants, ref, spec, errors) { } else { errors.push({ message: key + ': array expected, ' + typeof val + ' found', - line: val.__line__ + line: val ? val.__line__ : null }); return false; } @@ -189,7 +193,7 @@ function validateNative(key, val, spec, errors) { if (type !== spec) { errors.push({ message: key + ': ' + spec + ' expected, ' + (typeof val) + ' found', - line: val.__line__ + line: val ? val.__line__ : null }); return false; } else { @@ -208,4 +212,3 @@ function validateEnum(key, val, spec, errors) { return true; } } -