Implement PipeTransform returning a Date, use new Date(value) to parse, check isNaN(date.getTime()) to detect invalid strings, and throw BadRequestException with a clear message including the expected format. Optionally add range constraints for business-specific date validation.
new Date('invalid') does not throw — it returns an Invalid Date object; always check isNaN(date.getTime()).
Throw BadRequestException with the expected format in the message for good developer experience.
Return Date instance so the handler receives a typed value, not a raw string.
For timezone-sensitive APIs consider using a library like date-fns parseISO() instead of new Date().
Pair with @IsDate() from class-validator in DTOs for body date fields.