code: function run(config)
  {
    var errors = [];
    var desc;
  
    var maxRefDepth = 10;   // avoid infinite loops
    var depth = 0;
  
    while (depth < maxRefDepth &&
           config.schema &&
           Object.prototype.hasOwnProperty.call(config.schema, '$ref'))
    {
      var ref = uri.resolve(config.resolutionScope,
        decodeURI(config.schema.$ref));
      config.schema = config.schemaRegistry.get(ref);
  
      if (!config.schema) {
        desc = 'schema not available: ' + ref;
        errors.push(new Errors.ValidationError(undefined, undefined, undefined,
          undefined, undefined, desc));
        return errors;
      }
  
      config.resolutionScope = ref;
      depth++;
  
      if (depth >= maxRefDepth) {
        desc = 'maximum nested $ref depth of ' + maxRefDepth + ' exceeded; ' +
          'possible $ref loop';
        errors.push(new Errors.ValidationError(undefined, config.instanceContext,
          '$ref', undefined, undefined, desc));
        return errors;
      }
    }
  
    // empty schema - bail early
    if (Object.keys(config.schema).length === 0) { return errors; }
  
    // validate the type: if it isn't valid we can bail early
    errors = errors.concat(VALIDATOR_FUNCTIONS.type(config));
    if (errors.length) { return errors; }
  
    // test all applicable schema properties
    var props = getApplicableTests(config);
    for (var index = 0; index < props.length; ++index) {
      var prop = props[index];
      var fn = VALIDATOR_FUNCTIONS[prop];
      if (!fn) {
        fn = VALIDATOR_FUNCTIONS[prop] = require('./keywords/' + prop + '.js');
      }
      errors = errors.concat(fn(config));
    }
    return errors;
  }
docs: ****************************************************************** Run all applicable tests.  config values:  inst: instance to validate schema: schema to validate against resolutionScope: resolutionScope, instanceContext: current position within the overall instance schemaRegistry: a SchemaRegistry customFormatHandlers: custom handlers for the "format" keyword  ******************************************************************