Fix default options missing profiles (#829)
* Add minItems requirement for profiles array * Use minItems/maxItems for default value construction
This commit is contained in:
parent
8c2e078f17
commit
8d28477562
@ -15,6 +15,7 @@
|
||||
},
|
||||
"profiles": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
@ -653,6 +653,21 @@ class JsonSchemaValidator {
|
||||
value[i] = this.getValidValueOrDefault(propertySchema, value[i]);
|
||||
}
|
||||
|
||||
const minItems = schema.minItems;
|
||||
if (typeof minItems === 'number' && value.length < minItems) {
|
||||
for (let i = value.length; i < minItems; ++i) {
|
||||
const propertySchema = this._getPropertySchema(schema, i, value, null);
|
||||
if (propertySchema === null) { break; }
|
||||
const item = this.getValidValueOrDefault(propertySchema);
|
||||
value.push(item);
|
||||
}
|
||||
}
|
||||
|
||||
const maxItems = schema.maxItems;
|
||||
if (typeof maxItems === 'number' && value.length > maxItems) {
|
||||
value.splice(maxItems, value.length - maxItems);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user