UNPKG

serverless-offline

Version:

Emulate AWS λ and API Gateway locally when developing your Serverless project

14 lines (11 loc) 317 B
import { validate } from "jsonschema" export default function payloadSchemaValidator(model, body) { const result = validate(body, model) if (result.errors.length > 0) { throw new Error( `Request body validation failed: ${result.errors .map((e) => e.message) .join(", ")}`, ) } }