Skip to content

custom import  #135

@greatbooms

Description

@greatbooms

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions