本文整理汇总了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;
}
示例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;
}
示例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();
}
}
示例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();
}