Android CI / RC / Android · lint, tests, debug APK, release compile (push) Failing after 1m25s
DH V2 CI / API · typecheck, tests, build (push) Successful in 34s
DH V2 CI / WEB · typecheck, build (push) Successful in 20s
Production dependency audit / API · production dependencies (push) Successful in 9s
Production dependency audit / WEB · production dependencies (push) Successful in 9s
DH V2 CI / Docker / scripts contract (push) Successful in 1m16s
80 lines
2.0 KiB
TypeScript
80 lines
2.0 KiB
TypeScript
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;
|
|
|
|
@ValidateIf((dto: UpsertInspectionResponsibleDto) => (
|
|
dto.attendanceStatus === InspectionResponsibleAttendanceStatus.PRESENT
|
|
))
|
|
@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;
|
|
}
|