Is it possible to process some date before or after the validation is done ?
function isDateString(value){
// parse the string into a date object
const date = new Date(value);
// if the parsing failed or the resulting date is invalid, throw an error
return !isNaN(date.getTime())
}
export const DateStringModel = BasicModel(String).assert(isDateString);
export const Playlist = new ObjectModel({
//...
date: [DateStringModel],
//...
});
So the validation checks that the data is a valid date string. But them, how can I cast this value to a Date ?
Is it possible to process some date before or after the validation is done ?
So the validation checks that the data is a valid date string. But them, how can I cast this value to a Date ?