使用 Validation
验证:
import { validate } from "class-validator";
let post = new Post();
post.rating = 11; //不应该通过
post.email = "google.com"; //不应该通过
post.site = "googlecom"; //不应该通过
if (errors.length > 0) {
throw new Error(`Validation failed!`);
} else {