src/lib/index.js
function validateResponse(schema, response, options, done) {
  debug(`validating response for ${schema.endpoint}`);
  // testing status code
  if (schema.status) {
    should(response.status).eql(schema.status);
  }
  return validator.compileAsync(schema).then((validate) => {
    const valid = validate(response.body);
    if (!valid) {
      const errors = validate.errors;
      should(errors).not.be.ok();
      return done(errors);
    }
    if (schema.export) {
      const body = response.body;
      options.vars = options.vars || {};
      for (let dest in schema.export) {
        const propPath = schema.export[dest];
        _.set(options.vars, dest, _.get(body, propPath));
      }
    }
    return done(null, response);
  }).catch(done);
}
function validateResponse(schema, response, options, done) {
  debug(`validating response for ${schema.endpoint}`);
  // testing status code
  if (schema.status) {
    should(response.status).eql(schema.status);
  }
  return validator.compileAsync(schema).then((validate) => {
    const valid = validate(response.body);
    if (!valid) {
      const errors = validate.errors;
      should(errors).not.be.ok();
      return done(errors);
    }
    if (schema.export) {
      const body = response.body;
      options.vars = options.vars || {};
      for (let dest in schema.export) {
        const propPath = schema.export[dest];
        _.set(options.vars, dest, _.get(body, propPath));
      }
    }
    return done(null, response);
  }).catch(done);
}
function validateResponse ( schema , response , options , done ) { debug ( ` ${ schema . endpoint } ` ) ; // testing status code if ( schema . status ) { should ( response . status ) . eql ( schema . status ) ; } return validator . compileAsync ( schema ) . then ( ( validate ) => { const valid = validate ( response . body ) ; if ( ! valid ) { const errors = validate . errors ; should ( errors ) . not . be . ok ( ) ; return done ( errors ) ; } if ( schema . export ) { const body = response . body ; options . vars = options . vars || { } ; for ( let dest in schema . export ) { const propPath = schema . export [ dest ] ; _ . set ( options . vars , dest , _ . get ( body , propPath ) ) ; } } return done ( null , response ) ; } ) . catch ( done ) ; }
Validate a Http response using schema.
This handles the actual JSON schema validation.

@private
@param  {Object} schema - schema used to validate against
@param  {*} response - http response
@param  {Object} options - test configurations
@param  {Function} done - called once validation is completed

@TODO Remove our "extensions" i.e. any custom properties in the
schema that we have added for the purpose of the elbow utility.
Validate a Http response using schema . This handles the actual JSON schema validation .