1.0.7 • Published 5 years ago

lambda-validator v1.0.7

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

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[]

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago