prisma-generator-nestjs-dto icon indicating copy to clipboard operation
prisma-generator-nestjs-dto copied to clipboard

[Feature] Add Validation Annotations

Open alexbeattie42 opened this issue 2 years ago • 3 comments

Problem

I cannot add custom validation class annotations to the generated typescript classes from the prisma.schema

Feature Request

If there is a model that looks like this:

model Organization {
  id    String     @id @default(cuid())
  name  String  @unique
  email String
}

It would be nice to have the ability to add annotations as follows:

model Organization {
  id    String     @id @default(cuid())
  /// @IsNotEmpty()
  name  String  @unique
  /// @IsEmail()
  email String
}

that would create a class like this:

export class CreateOrganizationDto {
  @IsNotEmpty()
  name: string;

  @IsEmail()
  email: string;
}

alexbeattie42 avatar Apr 26 '22 16:04 alexbeattie42

Yea, the lack of this feature is going to prevent me from being able to use this library.

TroyMorvant avatar May 18 '22 20:05 TroyMorvant

A few months ago, I forked this repo to add some additional features according to our project needs. One of them was to include those class validation decorators. You may want to have a look and try here: https://www.npmjs.com/package/@brakebein/prisma-generator-nestjs-dto

Brakebein avatar Jul 25 '22 10:07 Brakebein

@Brakebein nice repo, i will try this and give start thank you

erlanggadewa avatar Aug 04 '22 13:08 erlanggadewa