lambda-validator
TypeScript icon, indicating that this package has built-in type declarations

1.0.7 • Public • Published

Pretty straightforward to run!

Installation

  • yarn add lambda-validator
  • yarn add class-transformer

Usage

import { Length } from 'class-validator'

// Create a class for the body and decorate it
class Body {
  @Length(5,20) name: string
}

// Example request usage
export const hello: APIGatewayProxyHandler = async (event, _context) => {
	const body = await ValidateBody(Body, event.body)

	return {
		statusCode: 200,
		body: JSON.stringify(body),
	}
}

API

Default function:

ValidateBody<Class>(targetType: Class, bodyString?: string | null, opts?: ValidatorOptions) => Promise<Class> Rejects with ValidationError[]

Package Sidebar

Install

npm i lambda-validator

Weekly Downloads

0

Version

1.0.7

License

MIT

Unpacked Size

9.61 kB

Total Files

8

Last publish

Collaborators

  • isaacnass