aws-lambda-handlers-ajv
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 AJV used for aws-lambda-handlers

Installation

npm i aws-lambda-handlers-ajv

Usage

import ajvValidation from 'aws-lambda-handlers-ajv';
import { LambdaFactoryManager } from 'aws-lambda-handlers';

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

const mgrWithValidation = ajvValidation( mgr );

export default mgrWithValidation;

The validator can then be used for runtime schema validation

import mgr from '/path/to/manager'

const schema = {
    type: "object",
    properties: {
        keyStr: {
            type: "string"
        },
        keyNum: {
            type: "number"
        }
    }
} as const;

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

/aws-lambda-handlers-ajv/

    Package Sidebar

    Install

    npm i aws-lambda-handlers-ajv

    Weekly Downloads

    4

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    13.8 kB

    Total Files

    11

    Last publish

    Collaborators

    • npellet