nestjs-class-validator-db
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

nestjs-class-validator-db

NPM version npm-typescript License

Installation

  npm install nestjs-class-validator-db
  or
  yarn add nestjs-class-validator-db

Usage :

// main.ts

import { useContainer } from 'class-validator'

async function bootstrap() {
    const app = await NestFactory.create(AppModule)
    app.useGlobalPipes(new ValidationPipe())
    useContainer(app.select(AppModule), { fallbackOnErrors: true })
    ...
}
bootstrap()
// app.module.ts

import { DbClassValidatorModule } from 'nestjs-class-validator-db'

@Module({
  imports: [
    ...
    DbClassValidatorModule
  ],
    ...
})
export class AppModule {}
// x.dto.ts

import { IsUnique } from 'nestjs-class-validator-db'
import { User } from '../entities/user.entity'

export class UserDto {
    @IsUnique(User)
    @IsEmail()
    email: string
}

Package Sidebar

Install

npm i nestjs-class-validator-db

Weekly Downloads

2

Version

2.0.0

License

ISC

Unpacked Size

12.4 kB

Total Files

20

Last publish

Collaborators

  • militant