| Total Complexity | 1 |
| Complexity/F | 1 |
| Lines of Code | 17 |
| Function Count | 1 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import {Inject, Injectable} from '@nestjs/common'; |
||
| 2 | import {ISpecification} from 'src/Domain/ISpecification'; |
||
| 3 | import {IUserRepository} from '../Repository/IUserRepository'; |
||
| 4 | import {User} from '../User.entity'; |
||
| 5 | |||
| 6 | @Injectable() |
||
| 7 | export class IsEmailAlreadyExist implements ISpecification { |
||
| 8 | constructor( |
||
| 9 | @Inject('IUserRepository') |
||
| 10 | private readonly userRepository: IUserRepository |
||
| 11 | ) {} |
||
| 12 | |||
| 13 | public async isSatisfiedBy(email: string): Promise<boolean> { |
||
| 14 | return (await this.userRepository.findOneByEmail(email)) instanceof User; |
||
| 15 | } |
||
| 16 | } |
||
| 17 |