Validate manual account creation

This commit is contained in:
MOHAN 2026-07-22 18:32:09 +05:30
parent 3163c9018f
commit 9629d4ea8f
2 changed files with 18 additions and 1 deletions

View File

@ -2,6 +2,7 @@ import { Body, Controller, Get, Param, Patch, Post, Query } from "@nestjs/common
import { ok } from "../common/response"; import { ok } from "../common/response";
import { AccountsService } from "./accounts.service"; import { AccountsService } from "./accounts.service";
import { CurrentUser } from "../common/decorators/current-user.decorator"; import { CurrentUser } from "../common/decorators/current-user.decorator";
import { CreateManualAccountDto } from "./dto/create-manual-account.dto";
import { UpdateAccountOwnershipDto } from "./dto/update-account-ownership.dto"; import { UpdateAccountOwnershipDto } from "./dto/update-account-ownership.dto";
@Controller("accounts") @Controller("accounts")
@ -27,7 +28,7 @@ export class AccountsController {
@Post("manual") @Post("manual")
async manual( async manual(
@CurrentUser() userId: string, @CurrentUser() userId: string,
@Body() payload: { institutionName: string; accountType: string; mask?: string }, @Body() payload: CreateManualAccountDto,
) { ) {
const data = await this.accountsService.createManualAccount(userId, payload); const data = await this.accountsService.createManualAccount(userId, payload);
return ok(data); return ok(data);

View File

@ -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;
}