14 lines
962 B
TypeScript
14 lines
962 B
TypeScript
import { Transform, Type } from 'class-transformer';
|
|
import { IsEnum, IsNumber, IsOptional, IsString, IsUUID, Max, MaxLength, Min, MinLength } from 'class-validator';
|
|
import { AreaOrganizationRole } from '../../database/entities';
|
|
|
|
export class CreateAreaCompanyRelationDto {
|
|
@IsUUID('4') areaId!: string;
|
|
@IsUUID('4') companyId!: string;
|
|
@IsOptional() @IsEnum(AreaOrganizationRole) relationRole: AreaOrganizationRole = AreaOrganizationRole.OPERATOR;
|
|
@IsOptional() @Type(() => Number) @IsNumber({ maxDecimalPlaces: 4 }) @Min(0.0001) @Max(100) participationPercent?: number | null;
|
|
@IsOptional() @Transform(({ value }) => typeof value === 'string' && value.trim() ? value.trim() : null) @IsString() @MaxLength(240) legalInstrument?: string | null;
|
|
@IsOptional() @IsUUID('4') sourceDocumentId?: string | null;
|
|
@Transform(({ value }) => (typeof value === 'string' ? value.trim() : value)) @IsString() @MinLength(3) @MaxLength(1000) reason!: string;
|
|
}
|