The exact error:
"value": "2019-10-09T10:36:40.791Z",
"property": "createdAt",
"children": [],
"constraints": {
"isDateString": "createdAt must be a ISOString"
}
The field in the class:
@prop({ default: new Date(Date.now()) })
@IsDefined()
@IsDateString()
createdAt: Date;
getting the document coming from the db:
const order = await this.order.findOne({
_id: body._id,
clientId: user.clientId,
});
calling the validator:
let orderData = order.toJSON();
let finalOrder = plainToClass(FinishedOrder, orderData);
let validation = await validateOrReject(finalOrder);
I've also tried to call order.toObject() but it has the same effect.