當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript z-schema.getLastErrors函數代碼示例

本文整理匯總了TypeScript中z-schema.getLastErrors函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript getLastErrors函數的具體用法?TypeScript getLastErrors怎麽用?TypeScript getLastErrors使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了getLastErrors函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: objectNormalize

  public objectNormalize(tx: IBaseTransaction<VoteAsset>): IBaseTransaction<VoteAsset> {
    const report = this.schema.validate(tx.asset, voteSchema);
    if (!report) {
      throw new Error(`Failed to validate vote schema: ${this.schema.getLastErrors()
        .map((err) => err.message).join(', ')}`);
    }

    return tx;
  }
開發者ID:RiseVision,項目名稱:rise-node,代碼行數:9,代碼來源:vote.ts

示例2: objectNormalize

  public objectNormalize(tx: IBaseTransaction<DelegateAsset>): IBaseTransaction<DelegateAsset> {
    removeEmptyObjKeys(tx.asset.delegate);

    const report = this.schema.validate(tx.asset.delegate, delegateSchema);
    if (!report) {
      throw new Error(`Failed to validate delegate schema: ${this.schema.getLastErrors()
        .map((err) => err.message).join(', ')}`);
    }

    return tx;
  }
開發者ID:RiseVision,項目名稱:rise-node,代碼行數:11,代碼來源:delegate.ts

示例3: validateAgainstSchemas

function validateAgainstSchemas(vlspec, done?) {
  var isVlValid = validator.validate(vlspec, vlSchema);
  var errors;

  if (!isVlValid) {
    errors = validator.getLastErrors();
    console.log(inspect(errors, { depth: 10, colors: true }));
  }
  assert.deepEqual(isVlValid, true);

  var vegaSpec = vl.compile(vlspec);

  var isVgValid = validator.validate(vegaSpec, vgSchema);

  if (!isVgValid) {
    errors = validator.getLastErrors();
    console.log(inspect(errors, { depth: 10, colors: true }));
  }
  assert.deepEqual(isVgValid, true);

  if (done) {
    done();
  }
}
開發者ID:MikeWickwar,項目名稱:firstyeoman,代碼行數:24,代碼來源:examples.test.ts

示例4: use

  public use(request: express.Request, response: any, next: (err?: any) => any) {
    castFieldsToNumberUsingSchema(
      transportSchema.headers,
      request.headers
    );
    if (!this.schema.validate(request.headers, transportSchema.headers)) {
      this.removePeer(request);
      return next(new Error(`${this.schema.getLastError().details[0].path
      } - ${this.schema.getLastErrors()[0].message}`));
    }
    if (!this.systemModule.networkCompatible(request.headers.nethash as string)) {
      this.removePeer(request);
      // TODO: convert this into an error.
      return next({
        expected: this.systemModule.getNethash(),
        message : 'Request is made on the wrong network',
        received: request.headers.nethash,
      });
    }

    if (!this.systemModule.versionCompatible(request.headers.version)) {
      this.removePeer(request);
      // TODO: Convert this into an error
      return next({
        expected: this.systemModule.getMinVersion(),
        message : 'Request is made from incompatible version',
        received: request.headers.version,
      });
    }

    // Add peer only if not firewalled
    if (typeof request.headers.firewalled === 'undefined' || request.headers.firewalled === 'false') {
      const p = this.peersLogic.create(this.computeBasePeerType(request));
      p.applyHeaders(request.headers as any);
      this.peersModule.update(p);
    }
    next();
  }
開發者ID:RiseVision,項目名稱:rise-node,代碼行數:38,代碼來源:validatePeerHeaders.ts


注:本文中的z-schema.getLastErrors函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。