(schema, throwOrLogError)
| 3762 | } |
| 3763 | // Validate schema against its meta-schema |
| 3764 | validateSchema(schema, throwOrLogError) { |
| 3765 | if (typeof schema == "boolean") |
| 3766 | return true; |
| 3767 | let $schema; |
| 3768 | $schema = schema.$schema; |
| 3769 | if ($schema !== undefined && typeof $schema != "string") { |
| 3770 | throw new Error("$schema must be a string"); |
| 3771 | } |
| 3772 | $schema = $schema || this.opts.defaultMeta || this.defaultMeta(); |
| 3773 | if (!$schema) { |
| 3774 | this.logger.warn("meta-schema not available"); |
| 3775 | this.errors = null; |
| 3776 | return true; |
| 3777 | } |
| 3778 | const valid = this.validate($schema, schema); |
| 3779 | if (!valid && throwOrLogError) { |
| 3780 | const message = "schema is invalid: " + this.errorsText(); |
| 3781 | if (this.opts.validateSchema === "log") |
| 3782 | this.logger.error(message); |
| 3783 | else |
| 3784 | throw new Error(message); |
| 3785 | } |
| 3786 | return valid; |
| 3787 | } |
| 3788 | // Get compiled schema by `key` or `ref`. |
| 3789 | // (`key` that was passed to `addSchema` or full schema reference - `schema.$id` or resolved id) |
| 3790 | getSchema(keyRef) { |
no test coverage detected