Skip to content

Commit

Permalink
Merge pull request #15 from toufiq-austcse/feature/error-handling
Browse files Browse the repository at this point in the history
feature: auth: signup validation
  • Loading branch information
toufiq-austcse committed May 6, 2023
2 parents ea4cb9a + 68379ca commit a121093
Showing 1 changed file with 36 additions and 6 deletions.
42 changes: 36 additions & 6 deletions src/api/auth/dto/req/auth-req.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,49 @@ import { IsEmail, IsNotEmpty, IsOptional, IsString, MinLength } from 'class-vali

export class SignUpReqDto {
@ApiProperty()
@IsEmail()
@IsNotEmpty()
@IsEmail({}, {
message: JSON.stringify({
key: 'email',
message: 'invalid email address'
})
})
@IsNotEmpty({
message: JSON.stringify({
key: 'email',
message: 'email is required'
})
})
email: string;

@ApiPropertyOptional()
@IsString()
@IsString({
message: JSON.stringify({
key: 'name',
message: 'name must be a string'
})
})
@IsOptional()
name: string;

@ApiProperty()
@IsString()
@IsNotEmpty()
@MinLength(5)
@IsString({
message: JSON.stringify({
key: 'password',
message: 'password must be a string'
})
})
@IsNotEmpty({
message: JSON.stringify({
key: 'password',
message: 'password is required'
})
})
@MinLength(5, {
message: JSON.stringify({
key: 'password',
message: 'password must be at least 5 characters'
})
})
password: string;
}

Expand Down

0 comments on commit a121093

Please sign in to comment.