File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { z } from 'zod/v4' ;
22import { createZodDto } from 'nestjs-zod' ;
3- import { createPaginationSchema } from '../../../ shared/schemas' ;
3+ import { createPaginationSchema } from '@ shared/schemas' ;
44
55export const CreateTeamSchema = z . object ( {
66 name : z . string ( ) . min ( 2 ) . max ( 100 ) . describe ( 'Название команды, отображаемое в интерфейсе' ) ,
@@ -13,6 +13,9 @@ export const CreateTeamSchema = z.object({
1313 tags : z
1414 . array ( z . string ( ) )
1515 . optional ( )
16+ . refine ( ( items ) => ! items || new Set ( items ) . size === items . length , {
17+ message : 'Теги в списке не должны повторяться' ,
18+ } )
1619 . describe ( 'Список строковых названий тегов для классификации' ) ,
1720} ) ;
1821
Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ export class TeamsService {
5050 }
5151
5252 const { tags, ...teamData } = dto ;
53+ const uniqueTags = tags ? [ ...new Set ( tags ) ] : [ ] ;
5354
5455 try {
5556 const result = await this . teamsRepo . create (
@@ -58,7 +59,7 @@ export class TeamsService {
5859 ...teamData ,
5960 slug : baseSlug ,
6061 } ,
61- tags ,
62+ uniqueTags ,
6263 ) ;
6364
6465 return {
You can’t perform that action at this time.
0 commit comments