使用 Validation

    验证:

    1. import { validate } from "class-validator";
    2. let post = new Post();
    3. post.rating = 11; //不应该通过
    4. post.email = "google.com"; //不应该通过
    5. post.site = "googlecom"; //不应该通过
    6. if (errors.length > 0) {
    7. throw new Error(`Validation failed!`);
    8. } else {