Android CI / RC / Android · lint, tests, debug APK, release compile (push) Successful in 3m41s
DH V2 CI / API · typecheck, tests, build (push) Successful in 31s
DH V2 CI / WEB · typecheck, build (push) Successful in 19s
Production dependency audit / API · production dependencies (push) Successful in 9s
Production dependency audit / WEB · production dependencies (push) Successful in 8s
DH V2 CI / Docker / scripts contract (push) Successful in 1m14s
62 lines
1.2 KiB
TypeScript
62 lines
1.2 KiB
TypeScript
import { Transform, Type } from 'class-transformer';
|
|
import {
|
|
IsInt,
|
|
IsOptional,
|
|
IsString,
|
|
IsUUID,
|
|
Matches,
|
|
Max,
|
|
MaxLength,
|
|
Min,
|
|
MinLength,
|
|
ValidateIf,
|
|
} from 'class-validator';
|
|
|
|
const optionalText = ({ value }: { value: unknown }) =>
|
|
typeof value === 'string' && value.trim() ? value.trim() : null;
|
|
|
|
export class CreateInspectionFindingDto {
|
|
@IsOptional()
|
|
@IsUUID('4')
|
|
clientGeneratedId?: string;
|
|
|
|
@IsUUID('4')
|
|
assetId!: string;
|
|
|
|
@IsOptional()
|
|
@Transform(optionalText)
|
|
@IsUUID('4')
|
|
catalogItemId?: string | null;
|
|
|
|
@ValidateIf((value: CreateInspectionFindingDto) => !value.catalogItemId)
|
|
@Transform(optionalText)
|
|
@IsString()
|
|
@MinLength(1)
|
|
@MaxLength(500)
|
|
customTitle?: string | null;
|
|
|
|
@IsOptional()
|
|
@Transform(optionalText)
|
|
@IsString()
|
|
@MaxLength(12000)
|
|
customLegalBasis?: string | null;
|
|
|
|
@Transform(({ value }) => (typeof value === 'string' ? value.trim() : value))
|
|
@IsString()
|
|
@MinLength(1)
|
|
@MaxLength(20000)
|
|
description!: string;
|
|
|
|
@IsOptional()
|
|
@Type(() => Number)
|
|
@IsInt()
|
|
@Min(1)
|
|
@Max(10)
|
|
severity?: number;
|
|
|
|
@IsOptional()
|
|
@Transform(optionalText)
|
|
@Matches(/^\d{4}-\d{2}-\d{2}$/)
|
|
correctionDueOn?: string | null;
|
|
}
|