1.0.7 • Published 1 year ago

aws-lambda-handlers-yup v1.0.7

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

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
    })
1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago