import { Transform } from 'class-transformer';
import { isString, toNumber } from 'lodash';

export const OptionalNumbersStringToNumbersArray = (defaultValue: unknown = []) =>
    Transform(({ value }) => {
        return value && isString(value) ? (value as string).split(',').map((stringNumber) => toNumber(stringNumber)) : defaultValue;
    });
