确切的错误:
"value": "2019-10-09T10:36:40.791Z",
"property": "createdAt",
"children": [],
"constraints": {
"isDateString": "createdAt must be a ISOString"
}
类中的字段:
@prop({ default: new Date(Date.now()) })
@IsDefined()
@IsDateString()
createdAt: Date;
获取来自数据库的文档:
const order = await this.order.findOne({
_id: body._id,
clientId: user.clientId,
});
调用验证器:
let orderData = order.toJSON();
let finalOrder = plainToClass(FinishedOrder, orderData);
let validation = await validateOrReject(finalOrder);
我也试过打电话order.toObject()
,但效果相同。