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) 277 B
import { Transform } from 'class-transformer'; export function ToNumber(options) { return Transform(function ToNumberTransform({ value }) { if (options?.optional && value === undefined) return undefined; return Number(value); }, options); }