code: function validateData(validator, schemaId, data, expected) {
      var result = validator.validate(schemaId, data);
      if (!result && expected || result && !expected) {
          if (!result) {
              return new Error(validator.errorsText());
          }
          else {
              return new Error('expected schema violation, but get conformity.');
          }
      }
  }
docs: validate the data against a schema
  @param {Object} validator - The JSON-Schema validator instance
  @param {String} schemaId - The schema id
  @param {Object} data - The data that to be validated
  @param {Boolean} expected - true if expect data conforms to schema, otherwise expect violation.
  @return {undefined | Error} - return undefined if the validation gets expected result; Otherwise
  throw error.