fix lof preview fail if less than 2 is selected

This commit is contained in:
Val Erastov 2019-02-19 13:32:59 -08:00
parent 30eb68774c
commit 500b084c2e
2 changed files with 9 additions and 1 deletions

View file

@ -2,7 +2,8 @@ export default {
sections: {
type: 'array',
itemType: 'loop',
initializeBySelection: true
initializeBySelection: true,
min: 2
},
boolean: {
type: 'enum',

View file

@ -62,6 +62,13 @@ export default function materializeParams(services, params, schema, result, erro
} else if (md.type === 'array') {
if (!Array.isArray(value)) {
errors.push({path: [...parentPath, field], message: 'not an array type'});
continue;
}
if (md.min !== undefined && value.length < md.min) {
errors.push({path: [...parentPath, field], message: 'required minimum ' + md.min + ' elements'});
}
if (md.max !== undefined && value.length > md.max) {
errors.push({path: [...parentPath, field], message: 'required maximum ' + md.max + ' elements'});
}
if (md.itemType === 'object') {
value = value.map((item , i) => {