Skip to content

custom import #135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
greatbooms opened this issue Sep 29, 2022 · 1 comment
Closed

custom import #135

greatbooms opened this issue Sep 29, 2022 · 1 comment

Comments

@greatbooms
Copy link

Hi, I have a question. I want to print a constant or dynamic message in the message option in class-validator, but I can't do my import statement at the top. Is there any way to solve this?

generator graphqlmodel {
  provider = "prisma-nestjs-graphql"
  output   = "../model/src/lib/@generated"
  reExport = All
  fields_ErrorMessage_from = "@temp/constants" 
  fields_ErrorMessage_defaultImport = "{ ErrorMessage }"
  fields_ErrorMessage_input = true
  fields_ErrorMessage_output = true
  fields_Validator_from = "class-validator"
  fields_Validator_namedImport = true
  fields_Validator_input = true
  fields_Validator_output = true
}

model User {
  /// @Validator.IsNotEmpty()
  /// @Validator.IsString()
  /// @Validator.MaxLength(191)
  id                 String         @id @default(cuid())
  /// @Validator.IsEmail({}, { message: ErrorMessage.MSG_EMAIL_RULES_VIOLATION, }, )
  /// @Validator.IsNotEmpty({ message: ErrorMessage.MSG_NOT_FOUND_EMAIL, } )
  /// @Validator.MaxLength(256)
  email              String?        @unique @db.VarChar(256)
}

import { ErrorMessage } from '@temp/constants';

dto file doesn't have that import

@unlight
Copy link
Owner

unlight commented Sep 29, 2022

No, it is not possible to have variables/dynamic values in directive comments.

Have you tried people solutions for class-validator?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants