62
rated 0 times
[
63]
[
1]
/ answers: 1 / hits: 20295
/ 4 Years ago, sat, february 15, 2020, 12:00:00
I have a DTO that looks like this:
class PersonDto {
readonly name: string;
readonly birthDate: Date;
}
My NestJs controller method looks like this:
@Post
create(@Body() person: PersonDto) {
console.log(New person with the following data:, person);
// more logic here
}
The JSON data that gets posted has birthDate
as a string: 2020-01-15
. How can I convert this string to a JavaScript Date
object? I'd like to add the @IsDate
class-validation to PersonDto
but currently that would fail.
More From » json