aboutsummaryrefslogtreecommitdiff
path: root/ext/js/data/options-util.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-05-22 15:45:20 -0400
committerGitHub <noreply@github.com>2021-05-22 15:45:20 -0400
commitd16739a83a20e1729e08dbcbbc155be15972d146 (patch)
treef7c12fa946a688750365ecf0f66227fcad4f927d /ext/js/data/options-util.js
parentb48052ff320f1a68aac317158c4c757a70b14f04 (diff)
Json schema validation improvements (#1697)
* Create new JsonSchema class * Add proxy handler * Update tests * Update validation scripts * Update backend * Update audio downloader * Update options util * Update dictionary importer * Update json schema file reference * Remove old json-schema.js * Rename new json-schema.js * Update file names * Rename class
Diffstat (limited to 'ext/js/data/options-util.js')
-rw-r--r--ext/js/data/options-util.js14
1 files changed, 7 insertions, 7 deletions
diff --git a/ext/js/data/options-util.js b/ext/js/data/options-util.js
index 00ad890d..740afa76 100644
--- a/ext/js/data/options-util.js
+++ b/ext/js/data/options-util.js
@@ -16,19 +16,19 @@
*/
/* global
- * JsonSchemaValidator
+ * JsonSchema
* TemplatePatcher
*/
class OptionsUtil {
constructor() {
- this._schemaValidator = new JsonSchemaValidator();
this._templatePatcher = null;
this._optionsSchema = null;
}
async prepare() {
- this._optionsSchema = await this._fetchAsset('/data/schemas/options-schema.json', true);
+ const schema = await this._fetchAsset('/data/schemas/options-schema.json', true);
+ this._optionsSchema = new JsonSchema(schema);
}
async update(options) {
@@ -87,7 +87,7 @@ class OptionsUtil {
options = await this._applyUpdates(options, this._getVersionUpdates());
// Validation
- options = this._schemaValidator.getValidValueOrDefault(this._optionsSchema, options);
+ options = this._optionsSchema.getValidValueOrDefault(options);
// Result
return options;
@@ -135,17 +135,17 @@ class OptionsUtil {
getDefault() {
const optionsVersion = this._getVersionUpdates().length;
- const options = this._schemaValidator.getValidValueOrDefault(this._optionsSchema);
+ const options = this._optionsSchema.getValidValueOrDefault();
options.version = optionsVersion;
return options;
}
createValidatingProxy(options) {
- return this._schemaValidator.createProxy(options, this._optionsSchema);
+ return this._optionsSchema.createProxy(options);
}
validate(options) {
- return this._schemaValidator.validate(options, this._optionsSchema);
+ return this._optionsSchema.validate(options);
}
// Legacy profile updating