hoangtm1601 / nest-base

A NestJS TypeORM MySQL Docker boilerplate project
110 stars 44 forks source link

TypeError: Cannot read property 'findByEmail' of undefined at UniqueEmailValidator.validate #21

Closed vanlanh10273 closed 3 years ago

vanlanh10273 commented 3 years ago

Can you help me to review this issue?Screen Shot 2021-09-05 at 10 59 58 AM

hoangtm1601 commented 3 years ago

Seems that userService cannot be injected into uniqueEmailValidator decorator, check your module first or you can ignore this decorator on DTO class.

vanlanh10273 commented 3 years ago

I was followed your source. I don't know why userService cannot inject to uniqueEmailValidator. How can I fix this?

hoangtm1601 commented 3 years ago

Oh, sorry to hear that because this repository was created more than 1 year ago so some components are deprecated. I will take a look soon. For the temporary solution, you can comment this line for continue testing. Feel free to contribute to this repo. Thank you ! https://github.com/hoangtm1601/nest-base/blob/master/src/users/dto/create-user.dto.ts#L8

vanlanh10273 commented 3 years ago

Okie, I'm waiting your help. I'm a newbie nestjs. :)

hoangtm1601 commented 3 years ago

Screenshot 2021-09-21 at 16 21 28 It currently works from my side with env:

vanlanh10273 commented 3 years ago

My nestjs version is 8.1.1 Can you add my skype is vanlanh10273?

hoangtm1601 commented 3 years ago

I think it's better to flow construction from Official docs. For your problem maybe you missed this configuration from class-validator on main.ts, so class-validator cannot inject UserService to your decorator class.

  useContainer(app.select(ValidatorModule), { fallbackOnErrors: true })

Refs: https://github.com/nestjs/nest/issues/528 Good luck!