Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
};