forked from Shared/esg
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
import { Transform } from 'class-transformer';
|
|
import { IsIn, IsNotEmpty, IsOptional, IsString, Length, Matches } from 'class-validator';
|
|
|
|
export class SayahRequestDto {
|
|
@ApiPropertyOptional({ example: '1', description: '1 for natural person' })
|
|
@IsOptional()
|
|
@IsString()
|
|
@IsIn(['1'])
|
|
accountOwnerType?: string;
|
|
|
|
@ApiProperty({ example: '4311402422', description: 'Iranian national code (10 digits)' })
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
@Length(10, 10)
|
|
@Matches(/^\d{10}$/, { message: 'nationalCode must be exactly 10 digits' })
|
|
nationalCode!: string;
|
|
|
|
@ApiPropertyOptional({
|
|
type: String,
|
|
example: '',
|
|
nullable: true,
|
|
description: 'Legal entity ID; use empty string for natural persons',
|
|
})
|
|
@IsOptional()
|
|
@IsString()
|
|
@Transform(({ value }: { value: unknown }) => {
|
|
if (value === null || value === undefined) {
|
|
return value;
|
|
}
|
|
if (typeof value === 'object') {
|
|
return '';
|
|
}
|
|
return String(value);
|
|
})
|
|
legalId?: string | null;
|
|
|
|
@ApiProperty({
|
|
example: 'IR800560611828005105117001',
|
|
description: 'Iranian Sheba ID (26 characters)',
|
|
})
|
|
@Transform(({ value }: { value?: string }) => value?.toUpperCase())
|
|
@IsString()
|
|
@Length(26, 26)
|
|
@Matches(/^IR\d{24}$/, { message: 'sheba must start with IR and contain 24 digits' })
|
|
sheba!: string;
|
|
}
|