Skip to content

Commit

Permalink
feat: [application] - should return result fail if not accepted terms…
Browse files Browse the repository at this point in the history
…in SingUpUseCase

#6
  • Loading branch information
Christiangsn committed Mar 8, 2023
1 parent f34063d commit 5ee5f1a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/@application/useCases/user/signup/signUpUseCases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@ import { type IUserRepositoryContract } from '@domain/contracts/repositories/use
import { Result } from '@domain/shared/core'
import { type ISignUpDTO } from './signupDTO'
import { useCases } from '@application/useCases/useCases'
import { Inject } from '@nestjs/common'

export interface IUseCases<DTO, Return> {
run: (props: DTO) => Promise<Return>
}
import { Inject, NotAcceptableException } from '@nestjs/common'

export class SignupUseCases extends useCases<ISignUpDTO> {
public constructor (
@Inject('IUserRepository')
private readonly userRepository: IUserRepositoryContract
) {
super('SignUp')
}
}

public async run (props: ISignUpDTO): Promise<Result<void>> {

if (!props.acceptedTerms) {
return Result.fail<void>('Terms should be accepted')
}

// Validar os DTO e se ocorreu um erro retornar
const emailOrError = EmailValueObject.create(props.email)
const passwordOrError = PasswordValueObject.create(props.password)
Expand Down

0 comments on commit 5ee5f1a

Please sign in to comment.