archetype-js
Advanced tools
Comparing version 0.2.9 to 0.2.10
{ | ||
"name": "archetype-js", | ||
"version": "0.2.9", | ||
"version": "0.2.10", | ||
"author": "Valeri Karpov <val@boosterfuels.com>", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
@@ -263,7 +263,18 @@ 'use strict'; | ||
if (Array.isArray(schema._paths[path].$enum)) { | ||
if (schema._paths[path].$enum.indexOf(val) === -1) { | ||
const msg = `Value "${val}" invalid, allowed values are ` + | ||
`"${inspect(schema._paths[path].$enum)}"`; | ||
error.markError(path, new Error(msg)); | ||
return; | ||
if (Array.isArray(val)) { | ||
_.each(val, (val, index) => { | ||
if (schema._paths[path].$enum.indexOf(val) === -1) { | ||
const msg = `Value "${val}" invalid, allowed values are ` + | ||
`"${inspect(schema._paths[path].$enum)}"`; | ||
error.markError([path, index].join('.'), new Error(msg)); | ||
return; | ||
} | ||
}); | ||
} else { | ||
if (schema._paths[path].$enum.indexOf(val) === -1) { | ||
const msg = `Value "${val}" invalid, allowed values are ` + | ||
`"${inspect(schema._paths[path].$enum)}"`; | ||
error.markError(path, new Error(msg)); | ||
return; | ||
} | ||
} | ||
@@ -270,0 +281,0 @@ } |
@@ -391,3 +391,6 @@ 'use strict'; | ||
$enum: ['steak and eggs', 'bacon and eggs'] | ||
} | ||
}, | ||
addOns: [ | ||
{ name: { $type: 'string', $enum: ['cheese', 'sour cream'] } } | ||
] | ||
}).compile(); | ||
@@ -399,5 +402,10 @@ | ||
assert.throws(function() { | ||
new Breakfast({ addOns: [{ name: 'maple syrup' }] }); | ||
}, /Value "maple syrup" invalid/); | ||
// works | ||
new Breakfast({ type: 'steak and eggs' }); | ||
new Breakfast({}); | ||
new Breakfast({ addOns: [{ name: 'cheese' }] }); | ||
}); | ||
@@ -404,0 +412,0 @@ |
40444
944