Fixed unique folder number

This commit is contained in:
Vincent Alamelle 2023-05-17 14:21:23 +02:00
parent 941163822c
commit 831733d090

View File

@ -47,10 +47,11 @@ export default class OfficeFoldersController extends ApiController {
//init OfficeFolder resource with request body values //init OfficeFolder resource with request body values
const officeFolderRessource = OfficeFolder.hydrate<OfficeFolder>(req.body); const officeFolderRessource = OfficeFolder.hydrate<OfficeFolder>(req.body);
await officeFolderRessource.validateOrReject?.({ groups: ["createFolder"] , forbidUnknownValues: false }); await officeFolderRessource.validateOrReject?.({ groups: ["createFolder"] , forbidUnknownValues: false });
const officeFolderNumberExist = await this.officeFoldersService.get({where: {folder_number: officeFolderRessource.folder_number}}); const officeFolderNumberExist = await this.officeFoldersService.get({where: {folder_number: officeFolderRessource.folder_number}});
if (officeFolderNumberExist) { if (officeFolderNumberExist.length > 0) {
this.httpValidationError(response, [{ this.httpValidationError(response, [{
property: "folder_number", property: "folder_number",
constraints: { constraints: {