How to use the z-schema.registerFormatSync function in z-schema

To help you get started, we’ve selected a few z-schema 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 derbyparty / racer-schema / lib / Schema.js View on Github external
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;
}