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

1.0.7 • Public • Published

Yup validation for AWS Lambda Handlers

Validation helper bundling yup used for aws-lambda-handlers

Installation

npm i aws-lambda-handlers-yup

Usage

import yupValidation from 'aws-lambda-handlers-yup';
import { LambdaFactoryManager } from 'aws-lambda-handlers';

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

const mgrWithValidation = yupValidation( mgr );

export default mgrWithValidation;

The validator can then be used for runtime schema validation

import mgr from '/path/to/manager'
import * as yup from 'yup';
import { InferType } from 'yup';

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

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

Package Sidebar

Install

npm i aws-lambda-handlers-yup

Weekly Downloads

1

Version

1.0.7

License

MIT

Unpacked Size

49.9 kB

Total Files

50

Last publish

Collaborators

  • npellet