1.0.7 • Published 6 years ago

lambda-validator v1.0.7

Weekly downloads
-
License
MIT
Repository
-
Last release
6 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

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago