generated from Seekra/repository-template
add settings configuration parser #78
@@ -57,24 +57,22 @@ function validateEntry(entry, path) {
|
|||||||
assertString(entry.name, `${path}.name`);
|
assertString(entry.name, `${path}.name`);
|
||||||
assertString(entry.i18n, `${path}.i18n`);
|
assertString(entry.i18n, `${path}.i18n`);
|
||||||
|
|
||||||
if (entry.default === undefined) {
|
if (entry.default !== undefined) {
|
||||||
throw new Error(`[settings] "${path}.default" is required`);
|
if (entry.type === 'bool' && typeof entry.default !== 'boolean') {
|
||||||
}
|
throw new Error(`[settings] "${path}.default" must be a boolean`);
|
||||||
|
}
|
||||||
if (entry.type === 'bool' && typeof entry.default !== 'boolean') {
|
if (entry.type === 'number' && typeof entry.default !== 'number') {
|
||||||
throw new Error(`[settings] "${path}.default" must be a boolean`);
|
throw new Error(`[settings] "${path}.default" must be a number`);
|
||||||
}
|
}
|
||||||
if (entry.type === 'number' && typeof entry.default !== 'number') {
|
if (entry.type === 'string' && typeof entry.default !== 'string') {
|
||||||
throw new Error(`[settings] "${path}.default" must be a number`);
|
throw new Error(`[settings] "${path}.default" must be a string`);
|
||||||
}
|
}
|
||||||
if (entry.type === 'string' && typeof entry.default !== 'string') {
|
if (entry.type === 'selection') {
|
||||||
throw new Error(`[settings] "${path}.default" must be a string`);
|
validateSelectionOptions(entry.options, path);
|
||||||
}
|
if (typeof entry.allowMultiple !== 'boolean') {
|
||||||
if (entry.type === 'selection') {
|
throw new Error(`[settings] "${path}.allowMultiple" must be a boolean`);
|
||||||
validateSelectionOptions(entry.options, path);
|
}
|
||||||
if (typeof entry.allowMultiple !== 'boolean') {
|
}
|
||||||
throw new Error(`[settings] "${path}.allowMultiple" must be a boolean`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user