Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function Schema(options) {
options = options || {};
options.validator = options.validator || {};
// Force sync mode so we can use sync 'validate' hook
options.validator.sync = true;
this.ZSchema = ZSchema;
if (options.formats) {
for (var format in options.formats) {
ZSchema.registerFormatSync(format, options.formats[format]);
}
}
this.customValidators = options.validators || {};
this.validator = new ZSchema(options.validator);
if (!options.schemas) throw new Error('Schemas are required in options');
// Compile and validate schemas
this.validator.compileSchema(options.schemas);
this.schemas = options.schemas;
}