{"id":48488,"library":"middy-standard-schema","title":"Middy Standard Schema Validator","description":"Middy middleware that validates events, contexts, or responses using any Standard Schema-compatible validation library (Zod, Arktype, Valibot, Joi, Yup, etc.). Version 1.0.0 is stable, with active development. It intelligently merges validated types into the event TypeScript type and provides opt-in detailed error exposure. Supports all modern Middy core versions (4-7) and dual CJS/ESM module output. Differentiators: library-agnostic via Standard Schema spec, optional event transformation, and flexible error handling.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/flubber2077/middy-standard-schema","tags":["javascript","middy","validation","validator","arktype","zod","valibot","middleware","typescript"],"install":[{"cmd":"npm install middy-standard-schema","lang":"bash","label":"npm"},{"cmd":"yarn add middy-standard-schema","lang":"bash","label":"yarn"},{"cmd":"pnpm add middy-standard-schema","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; required middleware framework","package":"@middy/core","optional":false}],"imports":[{"note":"ESM-only package; requires @middy/core as peer dependency. Use named import.","wrong":"const standardSchemaValidator = require('middy-standard-schema')","symbol":"standardSchemaValidator","correct":"import { standardSchemaValidator } from 'middy-standard-schema'"},{"note":"This is a TypeScript type; use 'import type' to avoid runtime errors.","wrong":"import { StandardSchemaValidatorOptions } from 'middy-standard-schema'","symbol":"StandardSchemaValidatorOptions","correct":"import type { StandardSchemaValidatorOptions } from 'middy-standard-schema'"},{"note":"Default export is the same function as named export. Prefer named import for consistency.","wrong":"const validator = require('middy-standard-schema')","symbol":"standardSchemaValidator (default export)","correct":"import validator from 'middy-standard-schema'"}],"quickstart":{"code":"import middy from '@middy/core';\nimport httpErrorHandler from '@middy/http-error-handler';\nimport { standardSchemaValidator } from 'middy-standard-schema';\nimport z from 'zod';\n\nconst eventSchema = z.object({\n  body: z.object({\n    HelloWorld: z.string()\n  })\n});\n\nconst baseHandler = async (event: any) => {\n  return { statusCode: 200, body: JSON.stringify({ message: event.body.HelloWorld }) };\n};\n\nexport const handler = middy(baseHandler)\n  .use(httpErrorHandler())\n  .use(standardSchemaValidator({ eventSchema }));","lang":"typescript","description":"Validates event body using Zod schema with middy-standard-schema, using @middy/core and error handler."},"warnings":[{"fix":"Set { transform: false } in options to disable event transformation.","message":"Validation transforms the event by default; parsed/replaced object may lose prototype methods.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use dynamic import or switch to ESM: import { standardSchemaValidator } from 'middy-standard-schema'.","message":"Using CommonJS require() will fail; this package is ESM-only (no CJS export).","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Update @middy/core to version ^4.0.0 or later.","message":"Peer dependency @middy/core must be v4, v5, v6, or v7; incompatible with v3 or earlier.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Use custom error handler instead of exposing errors to end users in production.","message":"Option exposeErrors: true may expose internal schema failure details in production responses.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'-7':59 '1.0.0':28 '4':58 'activ':32 'agnost':68 'arktyp':22,84 'cjs/esm':62 'compat':18 'context':10 'core':56 'detail':49 'develop':33 'differenti':65 'dual':61 'error':50,78 'etc':26 'event':9,41,74 'exposur':51 'flexibl':77 'handl':79 'intellig':35 'javascript':80 'joi':24 'librari':20,67 'library-agnost':66 'merg':36 'middi':1,5,55,81 'middlewar':6,87 'modern':54 'modul':63 'opt':47 'opt-in':46 'option':73 'output':64 'provid':45 'respons':12 'schema':3,17,71 'schema-compat':16 'spec':72 'stabl':30 'standard':2,15,70 'support':52 'transform':75 'type':38,43 'typescript':42,88 'use':13 'valibot':23,86 'valid':4,8,19,37,82,83 'version':27,57 'via':69 'yup':25 'zod':21,85","created_at":"2026-06-07T16:56:54.928703+00:00","updated_at":"2026-06-07T16:56:54.928703+00:00","problems":[{"fix":"npm install middy-standard-schema @middy/core && set moduleResolution to 'node16' in tsconfig.json.","cause":"Package not installed or tsconfig missing moduleResolution 'node16'/'nodenext' for ESM.","error":"Cannot find module 'middy-standard-schema' or its corresponding type declarations."},{"fix":"Change to dynamic import() or switch to ESM: use 'type': 'module' in package.json.","cause":"Using require() instead of import; package is ESM-only.","error":"ERR_REQUIRE_ESM: require() of ES Module /path/middy-standard-schema/index.mjs not supported."},{"fix":"Install @middy/core >=4.0.0 and ensure it is imported correctly: import middy from '@middy/core'.","cause":"Missing or incompatible @middy/core version.","error":"TypeError: middy(...).use is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/flubber2077/middy-standard-schema","github":"https://github.com/flubber2077/middy-standard-schema","docs":null,"changelog":null,"pypi":null,"npm":"middy-standard-schema","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}