Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/modules/teams/dtos/team.dto.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { z } from 'zod/v4';
import { createZodDto } from 'nestjs-zod';
import { createPaginationSchema } from '../../../shared/schemas';
import { createPaginationSchema } from '@shared/schemas';

export const CreateTeamSchema = z.object({
name: z.string().min(2).max(100).describe('Название команды, отображаемое в интерфейсе'),
Expand All @@ -11,8 +11,11 @@ export const CreateTeamSchema = z.object({
.describe('Краткое описание деятельности или целей команды'),
slug: z.string().optional().describe('Уникальная ссылка на изображение команду'),
tags: z
.array(z.string())
.array(z.string().toLowerCase())
.optional()
.refine((items) => !items || new Set(items).size === items.length, {
message: 'Теги в списке не должны повторяться',
})
.describe('Список строковых названий тегов для классификации'),
});

Expand Down
3 changes: 2 additions & 1 deletion src/modules/teams/services/teams.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export class TeamsService {
}

const { tags, ...teamData } = dto;
const uniqueTags = tags ? [...new Set(tags.map((tag) => tag.toLowerCase()))] : [];

try {
const result = await this.teamsRepo.create(
Expand All @@ -58,7 +59,7 @@ export class TeamsService {
...teamData,
slug: baseSlug,
},
tags,
uniqueTags,
);

return {
Expand Down
Loading