From 5205da572980f24d1632d0fa7df85124322ca960 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Tue, 3 Dec 2019 18:46:03 +0900 Subject: [PATCH] Make engines required --- src/shared/settings/Settings.ts | 2 +- src/shared/settings/schema.json | 3 ++- src/shared/settings/validate.js | 14 ++++++++++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/shared/settings/Settings.ts b/src/shared/settings/Settings.ts index f142717..97dda7f 100644 --- a/src/shared/settings/Settings.ts +++ b/src/shared/settings/Settings.ts @@ -44,7 +44,7 @@ export default class Settings { if (!valid) { let message = (validate as any).errors!! .map((err: Ajv.ErrorObject) => { - return `'${err.dataPath}' of ${err.keyword} ${err.message}`; + return `'${err.dataPath}' ${err.message}`; }) .join('; '); throw new TypeError(message); diff --git a/src/shared/settings/schema.json b/src/shared/settings/schema.json index 2e2f62a..31d47f1 100644 --- a/src/shared/settings/schema.json +++ b/src/shared/settings/schema.json @@ -33,7 +33,8 @@ } }, "required": [ - "default" + "default", + "engines" ] }, "properties": { diff --git a/src/shared/settings/validate.js b/src/shared/settings/validate.js index c761cee..236488d 100644 --- a/src/shared/settings/validate.js +++ b/src/shared/settings/validate.js @@ -143,7 +143,17 @@ var validate = (function() { if (valid2) { var data2 = data1.engines; if (data2 === undefined) { - valid2 = true; + valid2 = false; + validate.errors = [{ + keyword: 'required', + dataPath: (dataPath || '') + '.search', + schemaPath: '#/properties/search/required', + params: { + missingProperty: 'engines' + }, + message: 'should have required property \'engines\'' + }]; + return false; } else { var errs_2 = errors; if ((data2 && typeof data2 === "object" && !Array.isArray(data2))) { @@ -512,7 +522,7 @@ validate.schema = { } } }, - "required": ["default"] + "required": ["default", "engines"] }, "properties": { "type": "object",