diff --git a/lib/index.js b/lib/index.js index 5478e96..4055b5f 100644 --- a/lib/index.js +++ b/lib/index.js @@ -224,16 +224,19 @@ internals.parseSchema = (joiSchema, dynamicSchemas, keyName, path, parentIsArray if (keyName && parsedItem) { const prefixedItemArray = []; - for (let i = 0; i < internals.maximumElementsInArray; ++i) { + for (let i = 1; i <= internals.maximumElementsInArray; ++i) { prefixedItemArray.push(parsedItem.map((headerQuery) => { const key = Object.keys(headerQuery)[0]; let name; - if (label) { - name = parsedItem.length === 1 ? `${label} ${i}` : `${label} ${i} ${key}`; + if (label === '_') { + name = parsedItem.length === 1 || i === 1 ? `${key}` : `${key} ${i}`; + } + else if (label) { + name = parsedItem.length === 1 || i === 1 ? `${label} ${key}` : `${label} ${i} ${key}`; } else { - name = parsedItem.length === 1 ? `${keyName}_${i}` : `${keyName}_${i}.${key}`; + name = parsedItem.length === 1 ? `${keyName} ${i}` : `${keyName} ${i} ${key}`; } const sliced = headerQuery[key].slice();