Skip to content

Commit a78924b

Browse files
authored
chore : adds import to template file and changes class validator type…
2 parents 615b07c + 531b4e2 commit a78924b

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/generator/dto-generator.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,12 @@ export class DtoGenerator {
202202
}
203203

204204
if (schema.format === 'date') {
205+
decorators.push('@IsDate()');
206+
}
207+
208+
if(schema.format === 'date-time') {
205209
decorators.push('@IsDateString()');
206210
}
207-
208-
if (schema.format === 'date-time') {
209-
decorators.push('@IsDateTimeString()');
210-
}
211211

212212
if (schema.enum) {
213213
const enumName = this.getEnumName(name, schema.enum);

src/templates/dto.hbs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { ApiProperty } from '@nestjs/swagger';
22
import {
33
IsString, IsNumber, IsBoolean, IsArray, IsOptional,
4-
IsEmail, IsEnum, Min, Max, MinLength, MaxLength, Matches,
5-
ValidateNested, IsInt
4+
IsEmail, IsEnum, IsUUID, IsDateString,
5+
Min, Max, MinLength, MaxLength, Matches,
6+
ValidateNested, IsInt, IsDate,
67
} from 'class-validator';
78
import { Type } from 'class-transformer';
89

tests/generator/dto-generator.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe('DtoGenerator', () => {
4141
expect(result).toContain('@IsEmail()');
4242
expect(result).toContain('@IsUUID()');
4343
expect(result).toContain('@IsDateString()');
44-
expect(result).toContain('@IsDateTimeString()');
44+
expect(result).toContain('@IsDate()');
4545

4646
// String length validation
4747
expect(result).toContain('@MinLength(1)');

0 commit comments

Comments
 (0)