UNPKG

@buka/class-transformer-extra

Version:

class-transformer-extra contains methods that's aren't included in the class-transform package.

9 lines (8 loc) 275 B
import { Transform } from 'class-transformer'; export function ToDate(options) { return Transform(function ToDateTransform({ value }) { if (options?.optional && value === undefined) return undefined; return new Date(value); }, options); }