Make engines required

This commit is contained in:
Shin'ya Ueoka 2019-12-03 18:46:03 +09:00
parent 6c763aa14f
commit 5205da5729
3 changed files with 15 additions and 4 deletions

View file

@ -44,7 +44,7 @@ export default class Settings {
if (!valid) { if (!valid) {
let message = (validate as any).errors!! let message = (validate as any).errors!!
.map((err: Ajv.ErrorObject) => { .map((err: Ajv.ErrorObject) => {
return `'${err.dataPath}' of ${err.keyword} ${err.message}`; return `'${err.dataPath}' ${err.message}`;
}) })
.join('; '); .join('; ');
throw new TypeError(message); throw new TypeError(message);

View file

@ -33,7 +33,8 @@
} }
}, },
"required": [ "required": [
"default" "default",
"engines"
] ]
}, },
"properties": { "properties": {

View file

@ -143,7 +143,17 @@ var validate = (function() {
if (valid2) { if (valid2) {
var data2 = data1.engines; var data2 = data1.engines;
if (data2 === undefined) { 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 { } else {
var errs_2 = errors; var errs_2 = errors;
if ((data2 && typeof data2 === "object" && !Array.isArray(data2))) { if ((data2 && typeof data2 === "object" && !Array.isArray(data2))) {
@ -512,7 +522,7 @@ validate.schema = {
} }
} }
}, },
"required": ["default"] "required": ["default", "engines"]
}, },
"properties": { "properties": {
"type": "object", "type": "object",