假設我有以下路線:companies/{companyId}/departments/{departmentId}/employees是否可以分別驗證兩個資源ID(companyId,departmentId)?我嘗試了以下操作,但無法正常工作。class ResourceId { @IsNumberString() @StringNumberRange(...) // my custom validator id: number;}@Get(':companyId/departments/:departmentId/employees')getEmployees( @Param('companyId') companyId: ResourceId, @Param('departmentId') departmentId: ResourceId,) {}我在單一路徑中有多個參數的情況很多。我不想為每條路線創建單獨的驗證類。有沒有辦法以其他方式處理此問題?
是否可以驗證單個路由參數?
米琪卡哇伊
2021-03-29 11:15:13