import{validate,validateOrReject,Contains,IsInt,Length,IsEmail,IsFQDN,IsDate,Min,Max,}from"class-validator";exportclassPost{@Length(10,20)title:string;@Contains("hello")text:string;@IsInt()@Min(0)@Max(10)rating:number;@IsEmail()email:string;@IsFQDN()site:string;@IsDate()createDate:Date;}letpost=newPost();post.title="Hello";// should not passpost.text="this is a great post about hell world";// should not passpost.rating=11;// should not passpost.email="google.com";// should not passpost.site="googlecom";// should not passvalidate(post).then((errors)=>{// errors is an array of validation errorsif(errors.length>0){console.log("validation failed. errors: ",errors);}else{console.log("validation succeed");}});validateOrReject(post).catch((errors)=>{console.log("Promise rejected (validation failed). Errors: ",errors);});// orasyncfunctionvalidateOrRejectExample(input){try{awaitvalidateOrReject(input);}catch(errors){console.log("Caught promise rejection (validation failed). Errors: ",errors);}}