Skip to content

Commit

Permalink
Update error message
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtemKolodko committed Nov 15, 2024
1 parent ab2b9d9 commit bf0b5b2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/dto/user.dto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApiProperty } from '@nestjs/swagger';
import {IsString, MaxLength} from 'class-validator';
import {IsString, MaxLength, MinLength} from 'class-validator';
import {Transform, Type} from "class-transformer";

export class AddUserDto {
Expand All @@ -25,11 +25,13 @@ export class GetUsersDto {
}

const UsernameMaxLength = 20
const UsernameMinLength = 5

export class UpdateUserDto {
@ApiProperty({ type: String, required: true, default: '' })
@Transform((address) => address.value.trim().toLowerCase())
@MaxLength(UsernameMaxLength, { message: `username must not exceed ${UsernameMaxLength} characters` })
@MaxLength(UsernameMaxLength, { message: `Username must not exceed ${UsernameMaxLength} characters` })
@MinLength(UsernameMinLength, { message: `Username must be at least ${UsernameMinLength} characters long` })
@Type(() => String)
@IsString()
username: string;
Expand Down

0 comments on commit bf0b5b2

Please sign in to comment.