Files
backend/src/business-profile/dto/update-business-profile.dto.ts
T
Alireza HassaniandCursor d237d00f65 Make business profile address postal code optional.
Allow empty or missing postalCode on profile addresses so saves are not blocked by MinLength validation.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-04 18:42:22 +03:30

158 lines
2.5 KiB
TypeScript

import { Type } from 'class-transformer';
import {
IsArray,
IsIn,
IsInt,
IsOptional,
IsString,
MaxLength,
MinLength,
ValidateNested,
} from 'class-validator';
class BusinessPhoneNumberDto {
@IsOptional()
@IsString()
@MinLength(1)
label?: string;
@IsIn(['landline', 'cell'])
type!: 'landline' | 'cell';
@IsString()
@MinLength(3)
number!: string;
}
class BusinessSocialMediaDto {
@IsOptional()
@IsString()
whatsapp?: string;
@IsOptional()
@IsString()
telegram?: string;
@IsOptional()
@IsString()
instagram?: string;
@IsOptional()
@IsString()
linkedin?: string;
@IsOptional()
@IsString()
youtube?: string;
@IsOptional()
@IsString()
aparat?: string;
}
class BusinessAddressDto {
@IsOptional()
@IsString()
id?: string;
@IsOptional()
@IsString()
name?: string | null;
@IsString()
@MinLength(1)
province!: string;
@IsString()
@MinLength(1)
city!: string;
@IsString()
@MinLength(1)
address!: string;
@IsOptional()
@IsString()
@MaxLength(20)
postalCode?: string | null;
@IsOptional()
@IsString()
landline?: string | null;
}
export class UpdateBusinessProfileDto {
@IsOptional()
@IsString()
@MinLength(2)
nameEn?: string;
@IsOptional()
@IsString()
@MinLength(2)
nameFa?: string;
/** Single-line business title / tagline. */
@IsOptional()
@IsString()
@MaxLength(255)
title?: string;
@IsOptional()
@IsString()
about?: string;
@IsOptional()
@IsString()
vision?: string;
@IsOptional()
@IsArray()
@IsString({ each: true })
emails?: string[];
@IsOptional()
@IsArray()
@ValidateNested({ each: true })
@Type(() => BusinessPhoneNumberDto)
phoneNumbers?: BusinessPhoneNumberDto[];
@IsOptional()
@ValidateNested()
@Type(() => BusinessSocialMediaDto)
socialMedia?: BusinessSocialMediaDto;
@IsOptional()
@Type(() => Number)
@IsInt()
logoMediaId?: number | null;
@IsOptional()
@Type(() => Number)
@IsInt()
logoDarkMediaId?: number | null;
@IsOptional()
@Type(() => Number)
@IsInt()
faviconMediaId?: number | null;
/** Marketplace/storefront banner; recommended aspect 18:6 (3:1). */
@IsOptional()
@Type(() => Number)
@IsInt()
bannerMediaId?: number | null;
@IsOptional()
@IsArray()
@Type(() => Number)
@IsInt({ each: true })
categoryIds?: number[];
@IsOptional()
@IsArray()
@ValidateNested({ each: true })
@Type(() => BusinessAddressDto)
addresses?: BusinessAddressDto[];
}