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