feat: DTOs partagés pour la validation des données - Ajout des classes de transfert de données pour toutes les entités
This commit is contained in:
63
src/shared/dto/composant.dto.ts
Normal file
63
src/shared/dto/composant.dto.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import { IsString, IsOptional, IsNumber } from 'class-validator';
|
||||
import { Transform } from 'class-transformer';
|
||||
|
||||
export class CreateComposantDto {
|
||||
@IsString()
|
||||
name: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
machineId?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
parentComposantId?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
reference?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
prestataire?: string;
|
||||
|
||||
@IsOptional()
|
||||
@Transform(({ value }) => value === '' ? null : value)
|
||||
@IsNumber({}, { message: 'prix must be a valid number' })
|
||||
prix?: number | null;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
emplacement?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
typeComposantId?: string;
|
||||
}
|
||||
|
||||
export class UpdateComposantDto {
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
name?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
reference?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
prestataire?: string;
|
||||
|
||||
@IsOptional()
|
||||
@Transform(({ value }) => value === '' ? null : value)
|
||||
@IsNumber({}, { message: 'prix must be a valid number' })
|
||||
prix?: number | null;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
emplacement?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
typeComposantId?: string;
|
||||
}
|
||||
Reference in New Issue
Block a user