From 86a507fdf61944b7505062a7bf73fdd2ea54f493 Mon Sep 17 00:00:00 2001 From: cherif Date: Tue, 17 Jan 2023 10:29:32 +0100 Subject: [PATCH] add a max lenght for username --- .../nestjs/api_back/src/users/dto/create-users.dto.ts | 3 ++- .../svelte/api_front/src/pages/profile/ProfileSettings.svelte | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/srcs/requirements/nestjs/api_back/src/users/dto/create-users.dto.ts b/srcs/requirements/nestjs/api_back/src/users/dto/create-users.dto.ts index 8b1a2529..9b61c95a 100644 --- a/srcs/requirements/nestjs/api_back/src/users/dto/create-users.dto.ts +++ b/srcs/requirements/nestjs/api_back/src/users/dto/create-users.dto.ts @@ -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() diff --git a/srcs/requirements/svelte/api_front/src/pages/profile/ProfileSettings.svelte b/srcs/requirements/svelte/api_front/src/pages/profile/ProfileSettings.svelte index f4fa2699..a5058dee 100644 --- a/srcs/requirements/svelte/api_front/src/pages/profile/ProfileSettings.svelte +++ b/srcs/requirements/svelte/api_front/src/pages/profile/ProfileSettings.svelte @@ -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.`; }