aws-lambda-handlers-zod
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

Yup validation for AWS Lambda Handlers

Validation helper bundling zod used for aws-lambda-handlers

Installation

npm i aws-lambda-handlers-zod

Usage

import zodValidation from 'aws-lambda-handlers-zod';
import { LambdaFactoryManager } from 'aws-lambda-handlers';

const mgr = new LambdaFactoryManager();
// ...Compose mgr with other methods at wish

const mgrWithValidation = zodValidation( mgr );

export default mgrWithValidation;

The validator can then be used for runtime schema validation

import mgr from '/path/to/manager'
import { z } from "zod";

const schema = z.object( {
    keyStr: z.string(),
    keyNum: z.number()
});

const { handler } = mgr
    .apiGatewayWrapperFactory('handler')
    .setTsInputType<z.infer<typeof schema>>()
    .validateInput("zod", schema) // <== Note this line here
    .wrapFunc( async () => {
        //... Function logic
    })

/aws-lambda-handlers-zod/

    Package Sidebar

    Install

    npm i aws-lambda-handlers-zod

    Weekly Downloads

    1

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    11.8 kB

    Total Files

    11

    Last publish

    Collaborators

    • npellet