Skip to content
This repository has been archived by the owner. It is now read-only.
[Migrated to nestcloud repository]A Nest framework (node.js) module for validating request params.
TypeScript JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
.eslintrc.js
.gitignore
.npmignore
.prettierrc
README.md
index.d.ts
index.js
index.ts.js
package.json
tsconfig.json
tslint.json
yarn.lock

README.md

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 @nestcloud/validations class-validator

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`;
  }
}

Validators

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

Stay in touch

License

NestCloud is MIT licensed.

You can’t perform that action at this time.