Coerce Moment/Date to string with AJV

Viewed 298

How can I coerce an json object that uses moment/date for date fields into a schema that uses {type: "string", format: "date-time"} with AJV?

I've tried using a custom keyword, but this doesn't run if the data is not a string.

{
  myDate: moment()
}

Should convert to

{
  myDate: "2012-04-23T18:25:43.511Z"
}
0 Answers
Related