diff --git a/template/nestJs/src/.generate/i18n.generated.ts b/template/nestJs/src/.generate/i18n.generated.ts index 29ed12ea..dd9a5d6a 100644 --- a/template/nestJs/src/.generate/i18n.generated.ts +++ b/template/nestJs/src/.generate/i18n.generated.ts @@ -56,6 +56,7 @@ export type I18nTranslations = { "NOT_EMPTY": string; "IS_ARRAY": string; "NOT_EMPTY_HUMAN": string; + "TYPE_ERROR": string; }; }; /* prettier-ignore */ diff --git a/template/nestJs/src/i18n/enUS/validation.json b/template/nestJs/src/i18n/enUS/validation.json index 8ce72583..b21cb291 100644 --- a/template/nestJs/src/i18n/enUS/validation.json +++ b/template/nestJs/src/i18n/enUS/validation.json @@ -1,5 +1,6 @@ { "NOT_EMPTY": "{property} should not to be empty", "IS_ARRAY": "{property} should to be array", - "NOT_EMPTY_HUMAN": "{name} should not to be empty" + "NOT_EMPTY_HUMAN": "{name} should not to be empty", + "TYPE_ERROR": "{property} should to be {type}" } diff --git a/template/nestJs/src/i18n/zhCN/validation.json b/template/nestJs/src/i18n/zhCN/validation.json index 4f2f9889..b9486ecd 100644 --- a/template/nestJs/src/i18n/zhCN/validation.json +++ b/template/nestJs/src/i18n/zhCN/validation.json @@ -1,5 +1,6 @@ { "NOT_EMPTY": "{property} 不能为空", "IS_ARRAY": "{property} 应该为数组", - "NOT_EMPTY_HUMAN": "{name} 不能为空" + "NOT_EMPTY_HUMAN": "{name} 不能为空", + "TYPE_ERROR": "{property} 应该为 {type}" } diff --git a/template/nestJs/src/menu/dto/create-menu.dto.ts b/template/nestJs/src/menu/dto/create-menu.dto.ts index 4c22a64f..fe14df14 100644 --- a/template/nestJs/src/menu/dto/create-menu.dto.ts +++ b/template/nestJs/src/menu/dto/create-menu.dto.ts @@ -1,4 +1,4 @@ -import { IsNotEmpty } from 'class-validator'; +import { IsNotEmpty, IsString } from 'class-validator'; import { i18nValidationMessage } from 'nestjs-i18n'; import { I18nTranslations } from '../../.generate/i18n.generated'; import { ApiProperty } from '@nestjs/swagger'; @@ -40,10 +40,11 @@ export class CreateMenuDto { }) component: string; @ApiProperty({ - description: '菜单图标' + description: '菜单图标', + required: false, }) - @IsNotEmpty({ - message: i18nValidationMessage('validation.NOT_EMPTY'), + @IsString({ + message: i18nValidationMessage('validation.TYPE_ERROR', {type: 'string'}), }) icon: string; @ApiProperty({