nest-validations
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications, heavily inspired by Angular.

NPM Version Package License NPM Downloads Travis Linux Coverage Gitter Backers on Open Collective Sponsors on Open Collective

Description

This is a Nest module for validating request params.

Installation

$ npm i --save nest-validations

Quick Start

CatDto

import {IsNotEmpty} from 'class-validator';

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

CatController

import { Controller, Get, Post, Body, Put, Param, Delete } from '@nestjs/common';
import {IsValid, IsNotEmpty} from 'nest-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`;
  }
}

Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.

Stay in touch

License

Nest is MIT licensed.

Readme

Keywords

none

Package Sidebar

Install

npm i nest-validations

Weekly Downloads

0

Version

0.2.1

License

MIT

Unpacked Size

133 kB

Total Files

69

Last publish

Collaborators

  • zfeng