How to use the jsonschema.SchemaError function in jsonschema

To help you get started, we’ve selected a few jsonschema examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ENCODE-DCC / encoded / src / encoded / static / components / form.js View on Github external
validator.attributes.pattern = function validatePattern(instance, schema) {
    let error;
    if (typeof instance === 'string') {
        if (typeof schema.pattern !== 'string') throw new jsonschema.SchemaError('"pattern" expects a string', schema);
        if (!instance.match(schema.pattern)) {
            error = `does not match pattern ${JSON.stringify(schema.pattern)}`;
        }
    }
    return error;
};