import { Transform } from 'class-transformer';

export function TransformNumberArray(): PropertyDecorator {
  return Transform(({ value }) => {
    if (Array.isArray(value)) return value.map((item: string) => Number(item));

    return value
      .trim()
      .replace(/[\[\]]/g, '')
      .split(',')
      .map((item: string) => Number(item));
  });
}
