Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/nest-cloud/validations
- Owner: nest-cloud
- License: mit
- Created: 2018-05-16T07:30:02.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-12T01:41:53.000Z (about 2 years ago)
- Last Synced: 2024-10-30T01:56:51.320Z (4 months ago)
- Topics: nest, nest-validations, nestjs
- Language: TypeScript
- Homepage: https://github.com/nest-cloud/nestcloud
- Size: 25.4 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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
## 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).