diff --git a/src/accounts/accounts.controller.ts b/src/accounts/accounts.controller.ts index 2601800..e176143 100644 --- a/src/accounts/accounts.controller.ts +++ b/src/accounts/accounts.controller.ts @@ -2,6 +2,7 @@ import { Body, Controller, Get, Param, Patch, Post, Query } from "@nestjs/common import { ok } from "../common/response"; import { AccountsService } from "./accounts.service"; import { CurrentUser } from "../common/decorators/current-user.decorator"; +import { CreateManualAccountDto } from "./dto/create-manual-account.dto"; import { UpdateAccountOwnershipDto } from "./dto/update-account-ownership.dto"; @Controller("accounts") @@ -27,7 +28,7 @@ export class AccountsController { @Post("manual") async manual( @CurrentUser() userId: string, - @Body() payload: { institutionName: string; accountType: string; mask?: string }, + @Body() payload: CreateManualAccountDto, ) { const data = await this.accountsService.createManualAccount(userId, payload); return ok(data); diff --git a/src/accounts/dto/create-manual-account.dto.ts b/src/accounts/dto/create-manual-account.dto.ts new file mode 100644 index 0000000..0e6646f --- /dev/null +++ b/src/accounts/dto/create-manual-account.dto.ts @@ -0,0 +1,16 @@ +import { IsIn, IsOptional, IsString, MaxLength } from "class-validator"; + +export class CreateManualAccountDto { + @IsString() + @MaxLength(120) + institutionName!: string; + + @IsString() + @IsIn(["checking", "savings", "credit", "investment", "loan", "cash", "other"]) + accountType!: string; + + @IsOptional() + @IsString() + @MaxLength(12) + mask?: string; +}