From de17231f61a7014d9703fe059424a2f0f2d85cdc Mon Sep 17 00:00:00 2001 From: hailin Date: Wed, 24 Dec 2025 23:58:55 -0800 Subject: [PATCH] =?UTF-8?q?fix(kyc):=20=E4=B8=BA=20SubmitRealNameDto=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20class-validator=20=E8=A3=85=E9=A5=B0?= =?UTF-8?q?=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复 ValidationPipe whitelist 模式下属性被过滤的问题 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../src/api/controllers/kyc.controller.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/backend/services/identity-service/src/api/controllers/kyc.controller.ts b/backend/services/identity-service/src/api/controllers/kyc.controller.ts index 378dbe09..ca0c75cc 100644 --- a/backend/services/identity-service/src/api/controllers/kyc.controller.ts +++ b/backend/services/identity-service/src/api/controllers/kyc.controller.ts @@ -18,7 +18,9 @@ import { ApiResponse, ApiConsumes, ApiBody, + ApiProperty, } from '@nestjs/swagger'; +import { IsString, IsNotEmpty, Length, Matches } from 'class-validator'; import { KycApplicationService } from '@/application/services/kyc-application.service'; import { JwtAuthGuard, @@ -29,7 +31,18 @@ import { // ========== DTO 定义 ========== class SubmitRealNameDto { + @ApiProperty({ description: '真实姓名', example: '张三' }) + @IsString() + @IsNotEmpty({ message: '姓名不能为空' }) + @Length(2, 50, { message: '姓名长度需在2-50个字符之间' }) realName: string; + + @ApiProperty({ description: '身份证号码', example: '110101199001011234' }) + @IsString() + @IsNotEmpty({ message: '身份证号不能为空' }) + @Matches(/^[1-9]\d{5}(18|19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[\dXx]$/, { + message: '身份证号格式不正确', + }) idCardNumber: string; }