fix(settings): check the name and i18n before the checks for a section in validateEntry in the settings validator

This commit is contained in:
2026-06-04 15:15:37 +02:00
committed by Gitea
parent 5c8073d264
commit 122663e2e3
@@ -43,8 +43,10 @@ export const validateSelectionOptions = function validateSelectionOptions (optio
export const validateEntry = function validateEntry (entry, path) { export const validateEntry = function validateEntry (entry, path) {
assertType(entry.type, `${path}.type`); assertType(entry.type, `${path}.type`);
assertString(entry.name, `${path}.name`);
assertString(entry.i18n, `${path}.i18n`);
if (entry.type === 'section') { if (entry.type === 'section') {
assertString(entry.name, `${path}.name`);
if (!Array.isArray(entry.content)) { if (!Array.isArray(entry.content)) {
throw new Error(`[settings] "${path}.content" must be an array`); throw new Error(`[settings] "${path}.content" must be an array`);
} }
@@ -54,9 +56,6 @@ export const validateEntry = function validateEntry (entry, path) {
return; return;
} }
assertString(entry.name, `${path}.name`);
assertString(entry.i18n, `${path}.i18n`);
if (entry.default !== undefined) { if (entry.default !== undefined) {
if (entry.type === 'bool' && typeof entry.default !== 'boolean') { if (entry.type === 'bool' && typeof entry.default !== 'boolean') {
throw new Error(`[settings] "${path}.default" must be a boolean`); throw new Error(`[settings] "${path}.default" must be a boolean`);