add a max lenght for username
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import { IsBoolean, Matches, IsEmail, IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
||||
import { IsBoolean, Matches, MaxLength, IsEmail, IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
||||
import { isSet } from 'util/types';
|
||||
|
||||
export class CreateUsersDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@Matches(/^[a-zA-Z0-9'-_]+$/)
|
||||
@MaxLength(50)
|
||||
readonly username: string;
|
||||
readonly fortyTwoId: string;
|
||||
@IsEmail()
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
.then((response) => {
|
||||
if (!response.ok) {
|
||||
success.username = ''
|
||||
errors.username = "Use [a-zA-Z0-9] and - _ .";
|
||||
errors.username = "Max length : 50 . Use [a-zA-Z0-9] and - _ .";
|
||||
if (response.status === 409) {
|
||||
errors.username = `${set.username} is already in use, pick a different one.`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user