dto work
- vscode쪽에서 강제로 내는 에러 - .vscode/settings.json 에서 "js/ts.implicitProjectConfig.experimentalDecorators": true 필요
This commit is contained in:
@@ -1,21 +1,10 @@
|
|||||||
import {
|
import {
|
||||||
validate,
|
|
||||||
validateOrReject,
|
|
||||||
Contains,
|
|
||||||
IsInt,
|
IsInt,
|
||||||
Length,
|
|
||||||
IsEmail,
|
|
||||||
IsFQDN,
|
|
||||||
IsDate,
|
|
||||||
Min,
|
|
||||||
Max,
|
|
||||||
IsString,
|
IsString,
|
||||||
} from 'class-validator';
|
} from 'class-validator';
|
||||||
|
|
||||||
export class BasicQueryDTO {
|
export class BasicQueryDTO {
|
||||||
@IsInt()
|
@IsInt()
|
||||||
generalID!: number;
|
generalID!: number;
|
||||||
|
|
||||||
@IsString()
|
|
||||||
command!: string;
|
command!: string;
|
||||||
}
|
}
|
||||||
+13
-4
@@ -1,11 +1,20 @@
|
|||||||
//import 'reflect-metadata';
|
import 'reflect-metadata';
|
||||||
//import { BasicQueryDTO } from './api';
|
import { BasicQueryDTO } from './api/index.js';
|
||||||
|
import { validate } from 'class-validator';
|
||||||
|
|
||||||
export function test(){
|
export async function test(){
|
||||||
console.log("Hello World!");
|
console.log("Hello World!");
|
||||||
|
|
||||||
|
const dto = new BasicQueryDTO();
|
||||||
|
dto.command = 'None';
|
||||||
|
dto.generalID = 1.1;
|
||||||
|
|
||||||
|
const result = await validate(dto);
|
||||||
|
console.log(result);
|
||||||
|
//must be integer가 나타나야함
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
test();
|
await test();
|
||||||
|
|
||||||
export default {};
|
export default {};
|
||||||
Reference in New Issue
Block a user