chore: import DH V2 D5.6.4 production baseline
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
import { Transform } from 'class-transformer';
|
||||
import {
|
||||
IsEmail,
|
||||
IsEnum,
|
||||
IsOptional,
|
||||
IsString,
|
||||
MaxLength,
|
||||
MinLength,
|
||||
ValidateIf,
|
||||
} from 'class-validator';
|
||||
import {
|
||||
InspectionResponsibleAttendanceStatus,
|
||||
InspectionResponsibleDocumentType,
|
||||
} from '../../database/entities';
|
||||
|
||||
const trimOrUndefined = ({ value }: { value: unknown }) => (
|
||||
typeof value === 'string' && value.trim() ? value.trim() : undefined
|
||||
);
|
||||
|
||||
export class UpsertInspectionResponsibleDto {
|
||||
@IsEnum(InspectionResponsibleAttendanceStatus)
|
||||
attendanceStatus!: InspectionResponsibleAttendanceStatus;
|
||||
|
||||
@ValidateIf((dto: UpsertInspectionResponsibleDto) => (
|
||||
dto.attendanceStatus === InspectionResponsibleAttendanceStatus.PRESENT
|
||||
))
|
||||
@Transform(trimOrUndefined)
|
||||
@IsString()
|
||||
@MinLength(1)
|
||||
@MaxLength(200)
|
||||
fullName?: string;
|
||||
|
||||
@ValidateIf((dto: UpsertInspectionResponsibleDto) => (
|
||||
dto.attendanceStatus === InspectionResponsibleAttendanceStatus.PRESENT
|
||||
))
|
||||
@IsEnum(InspectionResponsibleDocumentType)
|
||||
documentType?: InspectionResponsibleDocumentType;
|
||||
|
||||
@ValidateIf((dto: UpsertInspectionResponsibleDto) => (
|
||||
dto.attendanceStatus === InspectionResponsibleAttendanceStatus.PRESENT
|
||||
))
|
||||
@Transform(trimOrUndefined)
|
||||
@IsString()
|
||||
@MinLength(1)
|
||||
@MaxLength(40)
|
||||
documentNumber?: string;
|
||||
|
||||
@ValidateIf((dto: UpsertInspectionResponsibleDto) => (
|
||||
dto.attendanceStatus === InspectionResponsibleAttendanceStatus.PRESENT
|
||||
))
|
||||
@Transform(trimOrUndefined)
|
||||
@IsString()
|
||||
@MinLength(1)
|
||||
@MaxLength(200)
|
||||
position?: string;
|
||||
|
||||
@IsOptional()
|
||||
@Transform(trimOrUndefined)
|
||||
@IsEmail()
|
||||
@MaxLength(320)
|
||||
email?: string;
|
||||
|
||||
@IsOptional()
|
||||
@Transform(trimOrUndefined)
|
||||
@IsString()
|
||||
@MaxLength(50)
|
||||
phone?: string;
|
||||
|
||||
@ValidateIf((dto: UpsertInspectionResponsibleDto) => (
|
||||
dto.attendanceStatus === InspectionResponsibleAttendanceStatus.ABSENT
|
||||
))
|
||||
@Transform(trimOrUndefined)
|
||||
@IsString()
|
||||
@MinLength(10)
|
||||
@MaxLength(4000)
|
||||
absenceReason?: string;
|
||||
}
|
||||
Reference in New Issue
Block a user