I'm currently working on implementing validation for the parameter I receive in a request, especially when trying to delete something. The parameter is expected to be a string but it must adhere to the format of a valid UUID. To achieve this, I have included a DTO (Data Transfer Object) to define the type of the parameter in the controller.
@Delete(':personId')
async deletePersonIdentity(@Param('personId') id:deletePersonIdentityDto) {
return this.personIdentityService.deletePersonIdentity(id.personId);
}
The structure of the DTO for deleting person identities is as follows.
export class deletePersonIdentityDto {
@ApiProperty({
example: 'fd914b72-a423-4256-99a1-aff78da9281f',
description: `ID of the Person`,
required: true,
})
@IsUUID()
readonly personId: string;
}
Despite passing a valid UUID as the parameter, I continue to receive a bad request error stating that the ID must be a UUID. This error is triggered by the class-validator module. Any suggestions on how to resolve this issue?