Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nest-cloud/validations

A Nest framework (node.js) module for validating request params.
https://github.com/nest-cloud/validations

nest nest-validations nestjs

Last synced: 3 months ago
JSON representation

A Nest framework (node.js) module for validating request params.

Awesome Lists containing this project

README

        

[travis-image]: https://api.travis-ci.org/nest-cloud/nestcloud.svg?branch=master
[travis-url]: https://travis-ci.org/nest-cloud/nestcloud
[linux-image]: https://img.shields.io/travis/nest-cloud/nestcloud/master.svg?label=linux
[linux-url]: https://travis-ci.org/nest-cloud/nestcloud

# NestCloud - Validations


NPM Version
Package License
NPM Downloads
Travis
Linux
Coverage

## Description

This is a [Nest](https://github.com/nestjs/nest) module for validating request params.

## Installation

```bash
$ npm i --save @nestcloud/validations class-validator
```

## Quick Start

#### CatDto

```typescript
import {IsNotEmpty} from 'class-validator';

export class CreateCatDto {
@IsNotEmpty()
readonly name: string;
readonly age: number;
readonly breed: string;
}
```

#### CatController

```typescript
import { Controller, Get, Post, Body, Put, Param, Delete } from '@nestjs/common';
import {IsValid, IsNotEmpty} from '@nestcloud/validations';

@Controller('cats')
export class CatsController {
@Post()
create(@Body(new IsValid()) createCatDto: CreateCatDto) {
return 'This action adds a new cat';
}

@Get()
findAll() {
return 'This action returns all cats';
}

@Get(':id')
findOne(@Param('id') id) {
return `This action returns a #${id} cat`;
}

@Put(':id')
update(@Param('id') id, @Body('name', new IsNotEmpty()) name) {
return `This action updates a #${id} cat`;
}

@Delete(':id')
remove(@Param('id') id) {
return `This action removes a #${id} cat`;
}
}
```

### More Validators

https://github.com/nest-cloud/validations/tree/master

## Stay in touch

- Author - [NestCloud](https://github.com/nest-cloud)

## License

NestCloud is [MIT licensed](LICENSE).