chore: change messages from hardcode to enum
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import { ApiProperty } from "@nestjs/swagger";
|
||||
import { ArrayMinSize, IsArray, IsBoolean, IsNotEmpty, IsOptional, IsString, IsUUID, MinLength } from "class-validator";
|
||||
import { IsArray, IsBoolean, IsNotEmpty, IsOptional, IsString, IsUUID, MinLength } from "class-validator";
|
||||
|
||||
import { AnnouncementMessage } from "../../../common/enums/message.enum";
|
||||
|
||||
export class CreateAnnouncementDto {
|
||||
@IsNotEmpty({ message: "عنوان نمیتواند خالی باشد" })
|
||||
@IsString({ message: "عنوان باید رشته باشد" })
|
||||
@IsNotEmpty({ message: AnnouncementMessage.TITLE_IS_REQUIRED })
|
||||
@IsString({ message: AnnouncementMessage.TITLE_STRING })
|
||||
@ApiProperty({
|
||||
type: String,
|
||||
description: "Title of the announcement",
|
||||
@@ -11,9 +13,9 @@ export class CreateAnnouncementDto {
|
||||
})
|
||||
title: string;
|
||||
|
||||
@IsNotEmpty({ message: "متن اطلاعیه نمیتواند خالی باشد" })
|
||||
@IsString({ message: "متن اطلاعیه باید رشته باشد" })
|
||||
@MinLength(10, { message: "متن اطلاعیه باید حداقل ۱۰ کاراکتر باشد" })
|
||||
@IsNotEmpty({ message: AnnouncementMessage.CONTENT_IS_REQUIRED })
|
||||
@IsString({ message: AnnouncementMessage.CONTENT_IS_STRING })
|
||||
@MinLength(10, { message: AnnouncementMessage.CONTENT_MUST_BE_LONGER })
|
||||
@ApiProperty({
|
||||
type: String,
|
||||
description: "Content of the announcement",
|
||||
@@ -31,7 +33,6 @@ export class CreateAnnouncementDto {
|
||||
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@ArrayMinSize(1, { message: "حداقل یک گروه باید انتخاب شود" })
|
||||
@IsUUID("4", {
|
||||
each: true,
|
||||
message: "شناسه هر گروه باید یک UUID معتبر نسخه ۴ باشد",
|
||||
|
||||
@@ -2,7 +2,7 @@ import { BadRequestException, Injectable, Logger } from "@nestjs/common";
|
||||
import slugify from "slugify";
|
||||
import { In, Not } from "typeorm";
|
||||
|
||||
import { RoleRepository } from "./roles.repository";
|
||||
import { RoleRepository } from "../repositories/roles.repository";
|
||||
// import { roles } from "../../../../database/seeders/role.seeder";
|
||||
import { CommonMessage, UserMessage } from "../../../common/enums/message.enum";
|
||||
import { CompleteRegistrationDto } from "../../auth/DTO/complete-register.dto";
|
||||
|
||||
Reference in New Issue
Block a user