Custom imports
Hi,
it would be nice to be able to configure custom imports. When you want to use a function for the "class-validator" right now you can`t import it automated. In this example i need to import the "createValidationError" function.
model customer {
/// @Validator.MaxLength(3, {message: createValidationError('form_string_max', ['max'])})
number BigInt @db.UnsignedBigInt
}
Will be missing
import { createValidationError } from '@m/common/utils/validation-helper';
In the generated input files.
A workaround is to create a dummy field decorator:
model customer {
/// @CustomValidation.dummy()
/// @Validator.MinLength(3, { message: CustomValidation.createError('form_string_min', ['min'])})
number BigInt @db.UnsignedBigInt
}
Added to generator section:
fields_CustomValidation_from = "@m/common/utils/validation-helper"
fields_CustomValidation_input = true
fields_CustomValidation_output = false
Will result in the wanted import:
import * as CustomValidation from '@m/common/utils/validation-helper';
But clearly rather ugly solution
It would be great if having some solutions for this, like triple slash to add custom imports...
@unlight Hello, sorry to tag you here. Could we please have your input on this issue? I plan to combine the nestjs-i18n library for validation messages. Importing it after code generation defeat the whole purpose.
Thanks again for your hard work
Merged https://github.com/unlight/prisma-nestjs-graphql/pull/230