|
@@ -325,21 +325,28 @@ class DefaultSchemaValidator implements ISchemaValidator {
|
|
|
* It is safe to call this function multiple times with the same plugin name.
|
|
|
*/
|
|
|
addSchema(plugin: string, schema: ISettingRegistry.ISchema): ISchemaValidator.IError[] | null {
|
|
|
- const validate = this._validator.getSchema('main');
|
|
|
- const valid = validate(schema);
|
|
|
-
|
|
|
- if (valid) {
|
|
|
- // Remove if schema already exists.
|
|
|
- this._composer.removeSchema(plugin);
|
|
|
- this._validator.removeSchema(plugin);
|
|
|
-
|
|
|
- // Add schema to the validator and composer.
|
|
|
- this._composer.addSchema(schema, plugin);
|
|
|
- this._validator.addSchema(schema, plugin);
|
|
|
- return null;
|
|
|
+ const composer = this._composer;
|
|
|
+ const validator = this._validator;
|
|
|
+ const validate = validator.getSchema('main');
|
|
|
+
|
|
|
+ if (!(validate(schema) as boolean)) {
|
|
|
+ return validate.errors as ISchemaValidator.IError[];
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!(validator.validateSchema(schema) as boolean)) {
|
|
|
+ return validator.errors as ISchemaValidator.IError[];
|
|
|
}
|
|
|
|
|
|
- return validate.errors as ISchemaValidator.IError[];
|
|
|
+ // Remove if schema already exists.
|
|
|
+ composer.removeSchema(plugin);
|
|
|
+ validator.removeSchema(plugin);
|
|
|
+
|
|
|
+ // Add schema to the validator and composer.
|
|
|
+ composer.addSchema(schema, plugin);
|
|
|
+ validator.addSchema(schema, plugin);
|
|
|
+
|
|
|
+ return null;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|