@appsemble/node-utils
Version:
NodeJS utilities used by Appsemble internally.
10 lines • 382 B
JavaScript
import { throwKoaError } from './koa.js';
export function handleValidatorResult(ctx, result, msg = 'JSON schema validation failed') {
if (!result.valid) {
if (ctx.response === undefined) {
throw new Error(msg, { cause: result.errors });
}
throwKoaError(ctx, 400, msg, { errors: result.errors });
}
}
//# sourceMappingURL=jsonschema.js.map