diff --git a/src/modules/catalogue/dto/create-catalogue.dto.ts b/src/modules/catalogue/dto/create-catalogue.dto.ts index c8bf445..ed3088e 100644 --- a/src/modules/catalogue/dto/create-catalogue.dto.ts +++ b/src/modules/catalogue/dto/create-catalogue.dto.ts @@ -1,7 +1,6 @@ -import { IsString, IsOptional, IsBoolean, IsInt, Min, IsEnum } from 'class-validator'; -import { ApiPropertyOptional, ApiProperty } from '@nestjs/swagger'; -import { Type } from 'class-transformer'; +import { IsString, IsEnum, Matches } from 'class-validator'; +import { ApiProperty } from '@nestjs/swagger'; import { CatalogueSize } from '../enums/company-status.enum'; export class CreateCatalogueDto { @@ -9,6 +8,12 @@ export class CreateCatalogueDto { @ApiProperty({ example: 'ایرانی' }) name: string; + @IsString() + @Matches(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, { + message: 'Slug must contain only lowercase English letters, numbers, and hyphens', + }) + @ApiProperty({ example: 'iranian-menu', description: 'URL-friendly slug (lowercase English letters, numbers, hyphens only)' }) + slug: string; @IsString() @ApiProperty() diff --git a/src/modules/catalogue/entities/catalogue.entity.ts b/src/modules/catalogue/entities/catalogue.entity.ts index 3b0ad6d..2aaa517 100644 --- a/src/modules/catalogue/entities/catalogue.entity.ts +++ b/src/modules/catalogue/entities/catalogue.entity.ts @@ -13,6 +13,9 @@ export class Catalogue extends BaseEntity { @Property({ type: "varchar", length: 255}) name!: string; + @Property({ type: "varchar", length: 255, nullable: false }) + slug!: string; + @Property({ type: "json" }) content!: string;